pax_global_header00006660000000000000000000000064150700153170014511gustar00rootroot0000000000000052 comment=00bca1fc6e2e5a077ba76a2fb29f533b3098274d alembic-1.8.9/000077500000000000000000000000001507001531700131245ustar00rootroot00000000000000alembic-1.8.9/.github/000077500000000000000000000000001507001531700144645ustar00rootroot00000000000000alembic-1.8.9/.github/actions/000077500000000000000000000000001507001531700161245ustar00rootroot00000000000000alembic-1.8.9/.github/actions/build-manylinux/000077500000000000000000000000001507001531700212455ustar00rootroot00000000000000alembic-1.8.9/.github/actions/build-manylinux/Dockerfile000066400000000000000000000003471507001531700232430ustar00rootroot00000000000000FROM quay.io/pypa/manylinux2010_x86_64:latest # Setup dev environment # WORKDIR /github/workspace ENV PLAT manylinux2010_x86_64 # Copy build script and build COPY build_alembic.sh /entrypoint.sh ENTRYPOINT [ "/entrypoint.sh" ] alembic-1.8.9/.github/actions/build-manylinux/build-manylinux.yml000066400000000000000000000002711507001531700251110ustar00rootroot00000000000000# action.yml name: 'Python 2.7 Manylinux Wheel' author: 'Stefan Jeske' description: 'Build manylinux wheels for a (Cython) Python package' runs: using: 'docker' image: 'Dockerfile' alembic-1.8.9/.github/actions/build-manylinux/build_alembic.sh000077500000000000000000000034221507001531700243600ustar00rootroot00000000000000#!/bin/bash # Debugging options set -e -x # Download dependencies from package server yum update -y && yum install -y wget cmake3 git zlib-devel curl openssl-devel # change into home dir cd /home/ # Download and build dependencies of alembic # Download, build and install python wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz tar -xzf Python-2.7.18.tgz cd Python-2.7.18 ./configure --enable-optimizations --enable-shared --enable-unicode=ucs4 make altinstall cd .. curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" python2.7 get-pip.py python2.7 -m pip install numpy # Boost 1.55 wget https://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/download -O boost.tar.gz tar -xzf boost.tar.gz cd boost_1_55_0 ./bootstrap.sh --with-libraries=program_options,python --with-python=/usr/local/bin/python2.7 ./b2 install cd .. && rm -rf boost_1_55_0 boost.tar.gz # Ilmbase wget http://download.savannah.gnu.org/releases/openexr/ilmbase-2.2.0.tar.gz tar -xzf ilmbase-2.2.0.tar.gz cd ilmbase-2.2.0 ./configure make install -j 4 cd .. && rm -rf ilmbase-2.2.0 ilmbase.2.2.0.tar.gz # PyIlmBase wget http://download.savannah.gnu.org/releases/openexr/pyilmbase-2.2.0.tar.gz tar -xzf pyilmbase-2.2.0.tar.gz cd pyilmbase-2.2.0 PYTHON=/usr/local/bin/python2.7 ./configure make -j 4 && make install cd .. && rm -rf pyilmbase-2.2.0 pyilmbase.2.2.0.tar.gz # Build Alembic cd /github/workspace/ # Default location of packages in docker action python2.7 setup.py bdist_wheel # Bundle external shared libraries into the wheels find . -type f -iname "*-linux*.whl" -execdir sh -c "auditwheel repair '{}' -w ./ --plat '${PLAT}' || { echo 'Repairing wheels failed.'; auditwheel show '{}'; exit 1; }" \; echo "Succesfully build wheels:" find . -type f -iname "*-manylinux*.whl" alembic-1.8.9/.github/workflows/000077500000000000000000000000001507001531700165215ustar00rootroot00000000000000alembic-1.8.9/.github/workflows/cifuzz.yml000066400000000000000000000012731507001531700205610ustar00rootroot00000000000000name: CIFuzz on: [pull_request] jobs: Fuzzing: runs-on: ubuntu-latest steps: - name: Build Fuzzers id: build uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master with: oss-fuzz-project-name: 'alembic' dry-run: false language: c++ - name: Run Fuzzers uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master with: oss-fuzz-project-name: 'alembic' fuzz-seconds: 300 dry-run: false language: c++ - name: Upload Crash uses: actions/upload-artifact@v4 if: failure() && steps.build.outcome == 'success' with: name: artifacts path: ./out/artifacts alembic-1.8.9/.github/workflows/main.yml000066400000000000000000000111411507001531700201660ustar00rootroot00000000000000# This is a basic workflow to help you get started with Actions name: CI # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the master branch on: push: # branches: [ master ] pull_request: # branches: [ master ] # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: linux: name: 'Linux VFX CY${{ matrix.vfx-cy }} <${{ matrix.compiler-desc }}, config=${{ matrix.build-type }}, cxx=${{ matrix.cxx-standard }}>' # GH-hosted VM. The build runs in CentOS 7 'container' defined below. runs-on: ubuntu-latest container: # DockerHub: https://hub.docker.com/u/aswf # Source: https://github.com/AcademySoftwareFoundation/aswf-docker image: aswf/ci-ocio:${{ matrix.vfx-cy }} strategy: matrix: build: [1,2,3,4] include: - build: 1 build-type: Release cxx-standard: 17 cxx-compiler: g++ cc-compiler: gcc compiler-desc: gcc11.2.1 vfx-cy: 2024 - build: 2 build-type: Release cxx-standard: 17 cxx-compiler: clang++ cc-compiler: clang compiler-desc: clang15.0 vfx-cy: 2024 - build: 3 build-type: Debug cxx-standard: 17 cxx-compiler: g++ cc-compiler: gcc compiler-desc: gcc11.2.1 vfx-cy: 2024 - build: 4 build-type: Debug cxx-standard: 17 cxx-compiler: clang++ cc-compiler: clang compiler-desc: clang15.0 vfx-cy: 2024 env: CXX: ${{ matrix.cxx-compiler }} CC: ${{ matrix.cc-compiler }} steps: - name: Checkout uses: actions/checkout@v2 - name: Create build directories run: | mkdir _install mkdir _build - name: Configure run: | cmake ../. \ -DCMAKE_INSTALL_PREFIX=../_install \ -DCMAKE_CXX_STANDARD=${{ matrix.cxx-standard }} working-directory: _build - name: Build run: | cmake --build . \ --target install \ --config ${{ matrix.build-type }} \ -- -j4 working-directory: _build - name: Test run: | ctest -T Test \ --timeout 7200 \ --output-on-failure \ -VV working-directory: _build # -------------------------------------------------------------------- macos: name: 'macOS VFXP-${{matrix.vfx-cy }} macos-${{ matrix.osver }} =) #-****************************************************************************** OPTION(USE_ARNOLD "Include Arnold stuff" OFF) OPTION(USE_BINARIES "Include binaries" ON) OPTION(USE_EXAMPLES "Include examples" OFF) OPTION(USE_HDF5 "Include HDF5 stuff" OFF) OPTION(USE_MAYA "Include Maya stuff" OFF) OPTION(USE_PRMAN "Include PRMan stuff" OFF) OPTION(USE_PYALEMBIC "Include PyAlembic stuff" OFF) OPTION(USE_STATIC_BOOST "Build with static Boost libs" OFF) OPTION(USE_STATIC_HDF5 "Build with static HDF5 libs" OFF) OPTION(USE_TESTS "Include Alembic tests" ON) OPTION(ALEMBIC_BUILD_LIBS "Build library, if off use external alembic libs" ON) OPTION(ALEMBIC_SHARED_LIBS "Build shared libraries" ON) OPTION(ALEMBIC_DEBUG_WARNINGS_AS_ERRORS "In debug mode build with warnings as errors" ON) SET(PYALEMBIC_PYTHON_MAJOR 3 CACHE STRING "Which major version of python to look for when building PyAlembic") option(DOCS_PATH "Create and install the HTML based API documentation to this location (requires Doxygen)" OFF) # Set static/dynamic build options SET(LIB_TYPE STATIC) IF (ALEMBIC_SHARED_LIBS) SET(LIB_TYPE SHARED) IF (WIN32) ADD_DEFINITIONS(-DALEMBIC_DLL) ENDIF() ENDIF(ALEMBIC_SHARED_LIBS) # Need to test this on multiple platforms, it is an easy way to enable # memory checks like valgrind by doing: # ctest -D ExperimentalMemCheck # include (CTest) # Cmake system specific flags SET(WINDOWS FALSE) IF ("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") SET(WINDOWS TRUE) ENDIF() SET(DARWIN FALSE) IF ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") SET(DARWIN TRUE) ENDIF() SET(LINUX FALSE) IF ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") SET(LINUX TRUE) ENDIF() # if not set fall back to VFX reference platform 2018 to 2020 IF ("${CMAKE_CXX_STANDARD}" STREQUAL "") MESSAGE("Defaulting CMAKE_CXX_STANDARD to 14") SET(CMAKE_CXX_STANDARD 14) SET(CMAKE_CXX_STANDARD_REQUIRED ON) ENDIF() # Set visibility for GNU compilers IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") ENDIF() # Set some debug vs opt flags if (ALEMBIC_DEBUG_WARNINGS_AS_ERRORS AND "${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND NOT MSVC) add_compile_options(-Wall -Werror -Wextra -Wno-unused-parameter -Wno-deprecated -Wunused-local-typedefs) if((CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0) OR CMAKE_CXX_COMPILER_ID MATCHES "CLANG") add_compile_options( -Wno-error=implicit-fallthrough) endif() endif() IF (NOT ${WINDOWS}) SET(EXTERNAL_MATH_LIBS "-lm") ELSE() SET(EXTERNAL_MATH_LIBS "") ENDIF() IF (MSVC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") IF ((CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15)) # MSVC15/MSVS2009 fix SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj" ) ENDIF () ADD_DEFINITIONS(-DPLATFORM_WINDOWS -DPLATFORM=WINDOWS) ELSEIF (${DARWIN}) #ADD_DEFINITIONS(-DPLATFORM_DARWIN -DPLATFORM=DARWIN "-arch x86_64") ADD_DEFINITIONS(-DPLATFORM_DARWIN -DPLATFORM=DARWIN) ELSE() ADD_DEFINITIONS(-DPLATFORM_LINUX -DPLATFORM=LINUX) ENDIF() #-****************************************************************************** # INSTALLATION #-****************************************************************************** IF (DEFINED ENV{ALEMBIC_INSTALL_PREFIX}) SET( CMAKE_INSTALL_PREFIX $ENV{ALEMBIC_INSTALL_PREFIX}/alembic-${PROJECT_VERSION}) ENDIF() # Tell me what my install location would be MESSAGE(STATUS "The install dir is ${CMAKE_INSTALL_PREFIX}") # check in the source directory SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/Modules) #-****************************************************************************** # TESTS #-****************************************************************************** # Globally enable testing ENABLE_TESTING() IF (BUILD_TESTING) SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard") MARK_AS_ADVANCED(BUILDNAME) ENDIF(BUILD_TESTING) IF (UNIX AND NOT WINDOWS) FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin ) IF (CMAKE_UNAME) EXECUTE_PROCESS(COMMAND uname -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR) SET(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL "processor type (i386 and x86_64)") IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") ADD_DEFINITIONS(-fPIC) ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") ENDIF(CMAKE_UNAME) ENDIF(UNIX AND NOT WINDOWS) IF (DARWIN) ADD_DEFINITIONS(-fPIC) ENDIF() #-****************************************************************************** # DEPENDENCIES #-****************************************************************************** FIND_PACKAGE(Threads REQUIRED) IF (DOCS_PATH) FIND_PACKAGE(Doxygen) ENDIF() # Imath, first look to see if we are bulding it with the source IF (TARGET Imath::Imath) set(Imath_FOUND ON) else() FIND_PACKAGE(Imath) endif() # HDF5 IF (USE_HDF5) FIND_PACKAGE(ZLIB REQUIRED) SET(ALEMBIC_WITH_HDF5 "1") INCLUDE("./cmake/AlembicHDF5.cmake") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DH5_USE_18_API") ENDIF() #-****************************************************************************** # BUILD LIBRARIES #-****************************************************************************** # Alembic IF (ALEMBIC_BUILD_LIBS) ADD_SUBDIRECTORY(lib) INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/lib" "${PROJECT_BINARY_DIR}/lib") ADD_LIBRARY( Alembic::Alembic ALIAS Alembic ) ELSE() FIND_PACKAGE(Alembic REQUIRED CONFIG HINTS ${ALEMBIC_ROOT}) MESSAGE(STATUS "Using external Alembic") ENDIF() # PyAlembic IF (USE_PYALEMBIC) FIND_PACKAGE(Python${PYALEMBIC_PYTHON_MAJOR} COMPONENTS Interpreter Development) if(Python${PYALEMBIC_PYTHON_MAJOR}_FOUND) MESSAGE(STATUS "Found Python ${Python${PYALEMBIC_PYTHON_MAJOR}_VERSION}") INCLUDE("./cmake/AlembicPyIlmBase.cmake") ADD_SUBDIRECTORY(python) else() MESSAGE(WARNING "Python not found! Skipping PyAlembic") endif() ENDIF() #-****************************************************************************** # BUILD BINARIES #-****************************************************************************** # PRMan IF (USE_PRMAN) INCLUDE("./cmake/AlembicPRMan.cmake") IF (${ALEMBIC_PRMAN_FOUND}) MESSAGE(STATUS "Building PRMan plugins") ADD_SUBDIRECTORY(prman) ELSE() MESSAGE(STATUS "PRMan not found") ENDIF() ENDIF() # Arnold IF (USE_ARNOLD) INCLUDE("./cmake/AlembicArnold.cmake") IF (${ALEMBIC_ARNOLD_FOUND}) MESSAGE(STATUS "Building Arnold plugins") ADD_SUBDIRECTORY( arnold ) ELSE() MESSAGE(STATUS "Arnold not found") ENDIF() ENDIF() # Maya IF (USE_MAYA) INCLUDE("./cmake/AlembicMaya.cmake") IF (MAYA_FOUND) MESSAGE(STATUS "Building Maya plugins") ADD_SUBDIRECTORY(maya) ELSE() MESSAGE(STATUS "Maya not found") ENDIF() ENDIF() # Binaries (abcls, abctree, etc) IF (USE_BINARIES) ADD_SUBDIRECTORY(bin) ENDIF() # Examples IF (USE_EXAMPLES) ADD_SUBDIRECTORY(examples) ENDIF() #-****************************************************************************** SET(_config_msg "\n * Alembic Configuration ===") MACRO(info_cfg_option _setting) SET(_msg " * ${_setting}") STRING(LENGTH "${_msg}" _len) WHILE("40" GREATER "${_len}") SET(_msg "${_msg} ") MATH(EXPR _len "${_len} + 1") ENDWHILE() SET(_config_msg "${_config_msg}\n${_msg}${${_setting}}") ENDMACRO() info_cfg_option(USE_ARNOLD) info_cfg_option(USE_BINARIES) info_cfg_option(USE_EXAMPLES) info_cfg_option(USE_HDF5) info_cfg_option(USE_MAYA) info_cfg_option(USE_PRMAN) info_cfg_option(USE_PYALEMBIC) info_cfg_option(USE_STATIC_BOOST) info_cfg_option(USE_STATIC_HDF5) info_cfg_option(USE_TESTS) info_cfg_option(ALEMBIC_SHARED_LIBS) info_cfg_option(ALEMBIC_DEBUG_WARNINGS_AS_ERRORS) info_cfg_option(PYALEMBIC_PYTHON_MAJOR) info_cfg_option(DOCS_PATH) MESSAGE("${_config_msg}") #-****************************************************************************** # PACKAGING (place at the end) #-****************************************************************************** set(CPACK_PACKAGE_CONTACT "Lucas Miller") # The following is distribution specific but leaving it here as an example for # the future (the example is for Ubuntu 22.04) # set(CPACK_DEBIAN_PACKAGE_DEPENDS "libimath-3-1-29") include(CPack) alembic-1.8.9/FEEDBACK.txt000066400000000000000000000027161507001531700150170ustar00rootroot00000000000000This is the 1.0 release of Alembic. We are confident it performs well, is feature complete, and is bug free enough to make the following promises: 1. Alembic Data will be backwards compatible with any version of the API. 2. Read performance will be the same or improve with future versions. 3. API will remain source code compatible unless read performance can be greatly improved. 4. Write performance will stay the same or improve unless read performance can be greatly increased. 5. Disk space usage will stay the same or improve unless read performance can be greatly increased. 6. Traversing the hierarchy must remain fast and not require much data loading/memory usage to guarantee on-demand loading. 7. Reading and writing the data for a specific node will not require the data of any other node for on-demand loading and writing. 8. Reading and writing a frame for a node will not require any other frame for on-demand loading and writing. There are several items that aren't in version 1.0 but will hopefully be included in a future patch: * Python bindings for the public-facing API. * Katana plugin * Houdini exporter Alembic is stable and usable, and any comments, criticisms or insights that you can provide are more than welcome. We hope you'll share your thoughts and feedback with us on alembic-discussion@googlegroups.com. To join the alembic-discussion mailing list, please visit http://groups.google.com/group/alembic-discussion. Thanks, The Alembic Team alembic-1.8.9/LICENSE.txt000066400000000000000000000114351507001531700147530ustar00rootroot00000000000000TM & © 2009-2015 Lucasfilm Entertainment Company Ltd. or Lucasfilm Ltd. All rights reserved. Industrial Light & Magic, ILM and the Bulb and Gear design logo are all registered trademarks or service marks of Lucasfilm Ltd. © 2009-2015 Sony Pictures Imageworks Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Industrial Light & Magic nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- ALEMBIC ATTACHMENT A — REQUIRED NOTICES FOR DISTRIBUTION The Alembic Software is distributed along with certain third party components licensed under various open source software licenses ("Open Source Components"). In addition to the warranty disclaimers contained in the open source licenses found below, Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ("ILM") makes the following disclaimers regarding the Open Source Components on behalf of itself, the copyright holders, contributors, and licensors of such Open Source Components: TO THE FULLEST EXTENT PERMITTED UNDER APPLICABLE LAW, THE OPEN SOURCE COMPONENTS ARE PROVIDED BY THE COPYRIGHT HOLDERS, CONTRIBUTORS, LICENSORS, AND ILM "AS IS" AND ANY REPRESENTATIONS OR WARRANTIES OF ANY KIND, WHETHER ORAL OR WRITTEN, WHETHER EXPRESS, IMPLIED, OR ARISING BY STATUTE, CUSTOM, COURSE OF DEALING, OR TRADE USAGE, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT WILL THE COPYRIGHT OWNER, CONTRIBUTORS, LICENSORS, OR ILM AND/OR ITS AFFILIATES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE OPEN SOURCE COMPONENTS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Boost C++ Libraries ------------------------------------------------------------------------ Boost Software License – Version 1.0 August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. alembic-1.8.9/NEWS.txt000066400000000000000000001620731507001531700144520ustar00rootroot000000000000002025-10-03, Alembic 1.8.9 Thanks to your feedback pull requests and submitted issues we have a few bug fixes and build enhancements. CMake: We are dropping build support for Ilmbase and python 2. We now require Imath 3+ and python 3+. Use Imath::PyImath component to find the python Imath bindings. (PR465 and PR468) Allow building Alembic source alongside Imath source. (PR467) Put CMake config files in ${CMAKE_INSTALL_LIBDIR}/cmake/Alembic instead of hard codeing lib/cmake/Alembic. (PR464) Include Imath headers the Imath 3 way, i.e. #include instead of #include (Issue 431) PyAlembic: Add DCCFPS hint support to CreateArchiveWithInfo (Issue 466) Ogawa: Better handle very large Ogawa version numbers. (PR472) 2024-12-02, Alembic 1.8.8 Thanks to your feedback and submitted issues we have a few bug fixes. Support variable order curves in the python bindings. (Issue 458) Support mingw64 by adding a missing include. (Issue 459) 2024-10-05, Alembic 1.8.7 Thanks to your feedback, pull requests, and submitted issues we have A few bugs and build enhancements. Combine CMake feedback from several PRs and issues. (PR457) Protect from potential buffer overrun because of malformed dimensions. (Issue 453) Fix a typo in the python bindings but leave the misspelled member (kkVisibilityVisible) to maintain compatibility. (Issue 440) Add unicode filename support for Windows (PR450) Make some of the extra python scripts including the PyAlembic and Maya unit tests python 3 compatible. (PR438) 2023-09-25, Alembic 1.8.6 Thanks to your feedback pull requests and submitted issues we have a few bug fixes and build enhancements. CMake: Introduce CPack to top level CMake. (PR 425) AbcCoreOgawa: Fix typo in a comment. (PR 417) AbcGeom: Fix bug with OCurves, ONuPatch, OPoints, OPolyMesh, and OSubD were not properly incrementing their number of set samples when using setFromPrevious. (PR 433) Util: Fix default values for float PODTraits. (PR 422) Windows: Support compiling with mingw. (PR 434) Explicitly call CreateFileA and CreateFileMappingA (instead of CreateFile and CreateFileMapping) since we are using std::string to open the file. (PR 435) AbcStitcher: Introduce -hold argument which will use the previous set sample instead of setting an empty sample for missing samples. (PR 432) 2023-03-13, Alembic 1.8.5 Thanks to your feedback pull requests and submitted issues we have a few bug fixes and build enhancements. Add test for fuzzer issue 53406. (PR415) Address Issue 402 by not using deprecated kWrapExisting calls when possible. Add missing vertex for cube test in the python bindings per Issue 407. Fix several warnings mentioned in Issue 309, 398 and 412. (PR413, PR414 and PR416) CMake: Don't explicitly set MACOSX_RPATH as it is set by default in CMake 3+. (PR404) Use install rpath for Imath 3. (PR405) Use STRING instead of PATH for ALEMBIC_LIB_INSTALL_DIR. (PR406) GitHub: Add CIFuzz as a GitHub action. (PR403) 2022-11-11, Alembic 1.8.4 Thanks to your feedback pull requests and submitted issues we have a few bug fixes and build enhancements. CMake: Add ALEMBIC_DEBUG_WARNINGS_AS_ERRORS to control the build in debug mode. It is set to ON by default to preserve the current behavior. Use add_compile_options instead of the older add_definitions. (PR371) Fix the include dirs for AbcCoreHDF5 tests. (PR382) Fix issue hinted at in Issue 223: use PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR when embedding Alembic within another CMake project. (PR393) AbcCoreOgawa: On Windows _BitScanForward64 is only available when _WIN64 is defined. When it is not, fall back on using _BitScanForward. (PR 373) Fuzzer issue 49213 turned up some new malformed MetaData memory problems. Indexed MetaData on the write side only allows 254 (plus the default empty one) small (up to 256 bytes), we now throw if we encounter malformed MetaData. We were also allowing empty property and object names through on the read side even though the writer forbids this. Finally integrate a couple of tests flagged by Taotao Gu's local fuzzer. (PR391 and PR397) Fuzzer issue 52939 showed that with certain malformed MetaData the pair separator should NOT occur before the assign separator. (PR396) PyAlembic: N2f and N2d properties were not being correctly bound.(PR390) 2021-09-11, Alembic 1.8.3 Thanks to your feedback and submitted issues we have a few bug fixes. Make sure we export the IlmBase requirement in CMake when using OpenEXR 2 to fulfill the Imath requirement. (Issue 355) Address report from GCC Undefined Behavior Sanitizer by initializing a couple of bools in OXform. (Issue 357) Fix compile issue when using C++17 with Microsoft Visual Studio and use a hopefully much faster find first bit set when using that compiler. (Issue 358) 2021-06-08, Alembic 1.8.2 Thanks to your feedback and submitted issues we have a few bug fixes. Ogawa: One of the fuzzer tests were was failing with 32 bit builds because of a different exception message. Fix a bug with 32 bit memory mapped Windows builds. CMake: Look for boost python a little differently, falling back on existing behavior. 2021-05-15, Alembic 1.8.1 Thanks to your feedback and submitted issues we have a few bug fixes. CMake: Get the python bindings building on MacOS. (Issue 340) Fix the capitalization of the Imath find_depencency in AlembicConfig.cmake so that Imath will be found when used by external projects. (Issue 341 and 343) Ogawa: Address Fuzzer issue 33685 sanity check that we have a valid group to avoid infinite recursion during traversal. 2021-04-17, Alembic 1.8.0 Thanks to your feedback and issues we have a few bug fixes and enhancements. API: We are dropping support for the ancient TR1 and expect the compilers to at least support C++std11, we currently default to C++std14. Because we now assume at least C++std11, we can remove ALEMBIC_LIB_USES_TR1 and ALEMBIC_LIB_USES_BOOST and we instead expect the std versions of things like shared_ptr. (Issue 312) Ogawa: Better support emscripten and ARM toolchains by using memcpy to avoid dereferencing non-aligned pointers. (PR 332) Python: Support building python3, and make it the default, to build the bindings against python2 use: -DUSE_PYALEMBIC=ON -DPYALEMBIC_PYTHON_MAJOR=2 Switch from __nonzero__ to __bool__ for the python3 bindings. (Issue 273) Workaround the testCollections crash. (Issue 274) Make the unit tests python 2 and python 3 compatible. (Issue 276) Rework the python testing framework so they can be run from CMake. (Issue 278) Switch from next to __next__ for the python3 bindings. (Issue 279) Utils: AbcStitcher: Propagate MetaData from the first of our ordered input archives over to the stitched output. (PR 324) CMake: Update the minimum requirement to 3.13 Overhaul to support the recently released Imath 3. (https://github.com/AcademySoftwareFoundation/Imath) Fix for using Alembic as a 3rd party with Imath 3. (Issue 337) Use Boost_VERSION_MACRO instead of Boost_VERSION. (PR 338) ======= 2020-10-23, Alembic 1.7.16 Thanks to your feedback,and pull requests a couple of bug fixes and a GitHub enhancement. GitHub: Add a Github Action to create a python 2.7 wheel. (PR 310) AbcCoreHDF5: Specify char signedness when setting the HDF5 data type as some architectures, like ARM, default to unsigned. (PR 316) AbcCoreOgawa: Fuzzer issue 25695: Fix leak that can occur when reading meta data, but the file is maliciously cut short. (PR 315) Fuzzer issue 26125: Add a check and throw an excpetion for an obviously recursive group. (PR 321) 2020-09-10, Alembic 1.7.15 Thanks to your feedback and issues we have a few bug fixes and an enhancement. AbcCoreOgawa: Fuzzer issues 25166, 25175, 25185, 25204, and 25236 all test for illegal meta data index values which we more carefully test. Fuzzer issue 25192 turned up a leak from a malformed file causing OrData to throw. Tests: Clang was flagging an unused variable in AbcMaterial tests. CMake: Add DOCS_PATH variable which will add Doxygen as a target and cause the generated html directory to be installed to that location. We remove the Doxygen file from the project and now use CMakes module to configure it. 2020-07-22, Alembic 1.7.14 Thanks to your feedback,issues, and pull requests we have several bug fixes and a few enhancements. API: Ogawa: Fix another Fuzzer issue with Ogawa::IData allocating too much memory because of a malicious file. Add tests for Fuzzer issues: 24846, 24853, 24598, 25051, and 25081. (PR296) Add support for the Haiku OS. (PR298) Murmur3: Add preprocessor define to support FreeBSD. (Issue 288) Remove Murmur3 from the LICENSE.txt since it was moved into the public domain a while ago, and is reflected as such in the code. (Issue 292) AbcGeom: Fix uninitialized member variable in OTypedGeomParam. (PR290) HDF: Remove some unused local functions. (Issue 293) Python bindings: Add GetArchiveStartAndEndTime. (PR291) Add optional dccFPS to the GetArchiveInfo dict. (PR294) 2020-07-11, Alembic 1.7.13 Thanks to your feedback and many issues submitted as well as a few pull requests we have several bug fixes. API: Ogawa: Google generously setup AutoFuzz and it found several issues when reading maliciously created files. These issues reported issues are fixed: 253-258, 269-272, 282, 283 (PR266) Maya: AbcImport: Add support for connecting MFnData::kFloatArray. Build: Fix issue where WFObjConvert headers were being put in the wrong place when installed. (Issue 264) Partly address Issue 265 by making some adjustments to the Doxyfile and remove a very old reference to MD5Hash in the very old Houdini SOP. Partly address issues outline in PR268, use MSVC instead of Windows variable as they are Visual Studio specific flags and define -Wno-error=implicit-fallthrough for CLANG and GCC 7 and up. 2019-10-25, Alembic 1.7.12 Thanks to your feedback and numerous pull requests we have several enhancements and bug fixes. API: Use critical section instead of mutex on Windows. (PR220) ErrorHandler now uses const char * for message instead of std::string for efficiency gain. (PR221) Fix incompatibilities with C++17. (PR237) Add optional DCC FPS hint when calling CreateArchiveWithInfo and GetArchiveInfo. (PR241) Maya: AbcExport: Support writing animated facesets. (PR217) AbcExport: Support per curve width. (PR239) AbcExport: When writing sparse data like just the UVs, create an OObject instead of an OXform. (PR241) Utils: WFOBJConvert: Fix bug where OBJ files with more than one shape would fail to properly convert UVs and Normals. (PR232) CMake: Make it easier to select the python version to build against. (PR215) 2019-5-16, Alembic 1.7.11 Thanks to your feedback and numerous pull requests we have several enhancements and bug fixes. CMake: Make ILMBase detection compatible with certain older versions. (PR207) Allow Alembic to build against a custom Python installation. (PR208) OpenMayaMac.h was removed from the DevKit since Maya 2016. (Issue210) API: Fix bug in OSubD where the detection of a partial sample was incorrect. Maya: AbcExport: Fix issue where certain user properties were incorrectly being written as arbGeomParams. (Issue 209) (PR211) AbcExport: Fix an issue with acyclic detection because of floating point inaccuracy. (PR213) 2018-12-5, Alembic 1.7.10 Thanks to your feedback and numerous pull requests we have several enhancements and bug fixes. API: Check to see if the OCompoundProperty already exists before trying to create a new one. (PR200, Issue 188) Explicitly include errno.h for compilers that don't bring it in as part of the other includes. (Issue 199) Maya: Support reading and writing nParticles as I/OPoints. (PR163) Houdini: Update the example SOP to work with Houdini 16.5, support layering, and take advantage of the Houdini API for faster geometry building. (PR196) 2018-9-7, Alembic 1.7.9 Thanks to your feedback and numerous pull requests we have several enhancements and bug fixes. API: Add memory mapped read support for Ogawa, which is now on by default but can be toggled off via Alembic::AbcCoreFactory::setOgawaReadStrategy. Read speed is improved by about 10-25% on Linux and potentially much more on Windows. (PR 187) Make getOrders and getKnots const on Alembic::AbcGeom::ICurves. (PR 162) Remove prefix _ in our include guards to be ISO conformant. (PR 192 and 194) Remove some unnecessary null pointer checks before deleting an object. (PR 193) When "wrapping" an IObject around the ISchemaObject properly copy the IObject so that the instancing info is copied over as well. (PR 195) Maya AbcImport/AbcExport: Update several deprecated Maya API function calls. (PR 173) Clean up some compiler warnings and add override keyword to a few methods. (PR 174) Prevent crash for importing certain invalid NURBS surfaces and add the error message when the NURBS surface can't be created. (PR 175) Alembic file translator now resolved in the same way as the AbcImport command. (PR 176) Fix per-face shader assignments not merging if the mesh to merge is an intermediate object. (PR 177) Utils: AbcStitcher: Fix crash when trying to stitch subd corner sharpness. ( PR 181 ) CMake: Use /bigobj flag for Visual Studio 2008/MSVC15. Use PyAlembic as a target and property name to avoid a naming conflict. Python binding alembic.so should be alembic.pyd on Windows. ( PR 172 ) Add the msvc14fixes.cpp for the python bindings if using MSVC 14 2015 Update 3. ##-***************************************************************************** 2018-4-30, Alembic 1.7.8 Thanks to your feedback and generous pull requests we have some enhancements. CMake: Add ability to specify where to install the Alembic libraries. (PR 165) Add option to NOT build the library. (PR 166) Add option to specify where to install the python module. (PR 167) Add option to specify where to intall the Maya plug-ins. (PR 168) Utils: AbcStitcher: Add verbose flag and try to accomodate stitching sampling with the same time sampling but with slightly different start times in the same IArchive. (PR 169) 2018-3-23, Alembic 1.7.7 Thanks to your feedback and pull requests we have a few bug fixes and an enhancement. API: Fix bug where std::weak_ptr was used in AbcCoreLayer instead of Alembic::Util::weak_ptr. Add OCurves::Schema::Sample::setPositionWeights to go along with the get. Expose it in the python bindings. prman Procedural: Add two options, -motionbegin and -motionend to explicitly control MotionBlocks. (PR 160) ##-***************************************************************************** 2018-3-7, Alembic 1.7.6 Thanks to your feedback and pull requests we have a few bug fixes. API: Fix memory issue when traversing an AbcCoreLayer hierarchy that also happens to use heavy instancing. (PR 151) Work around a pread OSX issue when trying to read data samples over 2 GB, by reading it in smaller chunks. (PR 153 and PR 155) Fix bug in AbcCoreLayer where the replace/prune logic was occurring in the opposite order of the data layering. We've adopted the data layering order style. (data in the first file specified overrides later files) (PR 156 and PR 157) Here is the canonical example order: sparseAnimatedPoints.abc sparseUVs.abc base.abc Python: Work around compiler bug in MSVC14 Update 3 involving boost::python. (PR 154) prman Procedural: Support widths on IPoints. (PR 147) Support visibility on IPolyMesh. (PR 148) ##-***************************************************************************** 2017-12-20, Alembic 1.7.5 Thanks to your feedback we have a bug fix: API: Fixed bug where getPropertiesHash and getChildrenHash were returning the wrong value for AbcCoreLayer archives that are made up of only on file. (PR 143) ##-***************************************************************************** 2017-10-12, Alembic 1.7.4 Thanks to your feedback and pull requests we have a few bug fixes and an enhancement. API: Do not allow scalar properties to match when they have the same data type but different extents. This is to avoid a segfault on getValue. (Issue 138) Add: const AbcA::ObjectWriterPtr getPtr() to OObject.h (PR 141) Remove an accidental circular include dependency in AbcCoreLayer. (PR 141) ##-***************************************************************************** 2017-8-9, Alembic 1.7.3 Thanks to your feedback we have a bug fix introduced in the previous release. API: Fix a bug where a file opened as Ogawa but not Ogawa would be closed twice causing issues on Windows. (Issue 135) ##-***************************************************************************** 2017-7-21, Alembic 1.7.2 Thanks to your feedback and pull requests we have a few bug fixes and enhancements. API: Fix bug with IFaceSet::getFaceExclusivity (Issue 129) When reading directly from a file with Ogawa use pread/ReadFile so we don't have to use a file descriptor per stream. (Issue 124) Misc: Propagate HDF5 dependency when doing a static build mentioned in Issue 126. (pull request 128) Fix up several other minor CMake issues mentioned in Issue 127. (also pull request 128) Make sure the shared library is given a major/minor version. (based on pull request 125) ##-***************************************************************************** 2017-3-24, Alembic 1.7.1 Thanks to your feedback and pull requests we have a few bug fixes and enhancements. API: Address Issues 110 and 114 make a few member functions const. Maya AbcExport: Fix call to isAnimated when writing Nurbs curves. Tools: Fix issue 101 which was a crash in abcls by being careful when printing certain strings. Rework AbcDiff so it better handles completely different hiearchies, and only attempts to do diffs on Ogawa files so we can take advantages of the computed hashes. Misc: Add continuous integration to the project via Travis. (pull request 98) Issue 104 turned up a problem with one of the tests when using newer versions of HDF5. This test can be removed. Fix small typo in code comments. (pull request 105) Make sure to use python 2, even if 3 can be found since some of the dependent binaries don't support it. (pull request 108) Fix typo in CMake Cxx11 variable name mentioned in Issue 115. ##-***************************************************************************** 2016-11-7, Alembic 1.7.0 Hello Alembic users, Thanks to your feedback we are introducing the new layering functionality to Alembic, as discussed here: https://groups.google.com/forum/#!topic/alembic-discussion/s0zm8VEBMOk AbcCoreLayer was developed collaboratively between Blizzard Entertainment and Sony Pictures Imageworks and is a way for you make sparse changes to an Alembic file by writing those changes into any number of other Alembic files, and combining them on read via AbcCoreLayer. Here are some examples of what you can do via layering: You can add additional properties to a shape. Example: Adding UVs to a polymesh that currently lack them You can override properties. Example: Override static points on a polymesh with animated points. You can add new objects. Example: Add a shape to an existing hierarchy. You can prune objects. Example: Remove shapes you don't like, or entire branches of the hierarchy. You can prune properties. Example: Removing incorrect normals. You can replace an object hierarchy with a different one. Example: You can replace separate curves groups with one big one. You can replace property hierarchy. Example: Don't like a bunch of properties in user properties? It can be replaced with a bunch of other properties, without needing to prune individual properties. AbcCoreLayer provides a SetPrune and SetReplace convenience function in Util.h, for setting up the MetaData appropriately. Maya: AbcImport: Support AbcCoreLayer by specifying more than one file to the AbcImport command. AbcExport: Support writing only UVs via -uvsonly or -uvo flag. Utilities: AbcDiff: Given 2 Alembic files, create a sparse diff between them. Other changes: API: Internally keep track of how many bytes we've written to reduce the number of potentially expensive calls on write. https://github.com/alembic/alembic/pull/90 Harden some unnecessary templated constructors in Abc and AbcGeom. Deprecate (but do not remove) constructors that take the kWrapExisting and kTop flag and provide reasonable constructors that don't use these flags in Abc and AbcGeom. ##-***************************************************************************** 2016-7-12, Alembic 1.6.1 Hello Alembic users, thanks to your feedback and reports we have a few bug fixes and enhancements. API: OPoints::setFromPrevious was not setting the previous velocity sample. (pull request 85) Fix small bug with AbcCoreOgawa::StreamManager COMPARE_EXCHANGE macro on Windows (pull request 86) Maya: Fix some unused variable warnings in AbcImport, AbcExport. Utils: AbcStitcher: Support stitching mixed indexed and non-indexed GeomParams. ##-***************************************************************************** 2016-6-30, Alembic 1.6.0 Thanks to your generous feedback and code contributions we are happy to announce the 1.6.0 release of Alembic. We've overhauled our build system, gotten rid of alembic_bootstrap.py in favor of going native CMake. We now better support Windows and also now require at least version 2.8.11 of CMake. For the latest build instructions please see: https://github.com/alembic/alembic/blob/master/README.txt Other changes include: Moved several core utilities out of examples and into bin. Make HDF5 an optional dependency. Allow install directory prefix to be explicitly set. (pull request 46) Add CMake generated configure file, so that the version of the project only needs to be set in one place, users know if Alembic was built without HDF5 support, and whether it is using tr1, boost, or neither. (C++11) as a dependency. API: Add ability to create a Windows dll, and add symbol visibility flags for other compilers. (pull request 14) Improve Ogawa write speeds on Windows by adding a larger buffer. (pull request 38) Make the 3 int values on OSubD optional. (faceVaryingInterpolateBoundary, faceVaryingPropagateCorners, and interpolateBoundary issue 34) Remove unnecessary scoped static initialization of some variables. (issue 27) Arnold Procedural: Add Ogawa support. (pull request 20) Maya: Support exporting MFnFloatArray. (pull request 45) Fix bug when Nurbs curves group are only animated via the transforms and speed up the isAnimated check. (pull request 82) Many AbcImport/AbcExport changes based on feedback and contributions from Autodesk, and to bring the plugins more into line with what is in the devkit. (pull request 51 and 62 through 79) ##-***************************************************************************** 2015-1-15, Alembic 1.5.8 Hello Alembic users, thanks to your feedback and reports we have a few bug fixes and enhancements. API: AbcCoreAbstract: Fix wstring array hash calculation. (pull request 17) Build system: Make the OS X version check more robust to determine if C++11 flag is required. (pull request 18) Python: PyAlembic: Add asOgawa option for PyOArchive and make Ogawa the default for CreateArchiveWithInfo. (pull request 16) ##-***************************************************************************** 2015-12-09, Alembic 1.5.7 Hello Alembic users, thanks to your feedback and reports we have a few bug fixes and enhancements. Python: Add missing methods to IPoints. Add Points schema to cask. (pull request 12) Cask: Add oproperty mapping for additional imath classes. Add iproperty to oproperty class mapping using pod, extent values. Remove named oproperty override mapping (replaced by above methods). Add metadata accessor to property class. Fix is_deforming method on objects. (pull request 15) Maya: AbcExport: Add support for writing out all UV sets on an MFnMesh with the -wuvs/-writeUVSets flag. (pull request 13) AbcImport: Support loaidng multiple UV sets on an MFnMesh when present. (pull request 13) ##-***************************************************************************** 2015-10-17, Alembic 1.5.6 Hello Alembic users, thanks to your feedback and reports we have a few bug fixes and enhancements. API: AbcCoreAbstract: Improve stability of TimeSamplingType equality comparison. (pull request 11) Maya: AbcExport: Recognize "faceVaryingInterpolateBoundary" not "facVaryingInterpolateBoundary" plug when writing out an MFnMesh as a SubD. (pull request 6) Don't produce an error for meshes without valid per-face mapping, e.g. whole object mappings. (pull request 6) Only create face sets for shading groups applied with with per-face mappings. (pull request 6) Make sure a schema that is detected to be static is written out with the default time sampling. (pull request 7) AbcImport: Don't warn about UVs or normals size being mismatched if the mesh has no points. (pull request 8) Connections to custom VectorArray and PointArray properties will no longer fail. (pull request 8) Support varying or vertex color properties and unpacking them into facevarying as Maya requires. (pull request 8) Only call setUsedAsColor for attributes that are constant scoped. (pull request 8) Utilities: AbcStitcher: Revamp AbcStitcher to better handle cases where certain shapes or properties may not exist in some of the files. (pull request 7) Build system: Boost_PYTHON_LIBRARY is case sensitive. (pull request 8) ##-***************************************************************************** 2014-07-15, Alembic 1.5.5 Hello Alembic users, thanks to your feedback and reports we have a few bug fixes and enhancements. API: AbcGeom: Fix bug in OSubD::setHoles where corner indices were being set instead. AbcCoreAbstract: Improve lookup times and numerical stability of TimeSampling. AbcOpenGL: Camera rotations are now done in X,Y,Z order instead of Z,X,Y Python API: PyAlembic: Address Issue 347, expose the CoreType in python. PyAbcOpenGL: Wrap ALEMBIC_LIB_USES_BOOST around get_pointer. Maya: AbcExport: If a shading group has an attribute named AbcFaceSetName, use that attribute instead of the shading groups name for the face set name. Fix for Issue 339, some dag nodes can't be pushed onto MDagPath, so make sure the push was successful to avoid infinite recursion. Fix for Issue 342, for improved performance skip over shadingEngines and subgraphs in util::isAnimated. AbcImport: Set AbcFacesetName attribute on newly created shadingGroups. Fix bug with open form check on curves. Fix bug with restoring knots from a curve group with more than one curve. Tools: AbcView: Fix for Issue 344, show array property values of length 1. Improve performance for some graphics cards by adjusting some drawing options. (also done in SimpleAbcViewer) abcls Add -v option to automatically display the first sample of all properties. Print an error message when seg fault is detected. cask: Fix for Issue 345, handle V3d and double array on write. Default to Ogawa on write. Fix for Issue 346, TimeSampling is now preserved for properties that are copies on write. ##-***************************************************************************** 2014-03-28, Alembic 1.5.4 Hello Alembic users, thanks to your feedback and reports we have a few bug fixes and enhancements. API: AbcGeom: Fix for Issue 333, optional property samples not being filled in correctly after being defined previously but not set on the current sample. AbcOpenGL: Fix for Issue 324, adjust dolly and clipping plane values when they get a bit extreme. Python: Updates for sphix docs AbcView: Fix static normals on animated archives. Fix remove item bug. Fix import session fle bug. Add Review mode. Support custom scripts. Maya: AbcExport: Write out NURBS curves as actual NURBS curves. AbcImport: Support reading NURBS curves. Use Alembic::Util::shared_ptr instead of std::tr1::shared_ptr in one spot. Util: AbcEcho: Fix bounds calculation on AbcBoundsEcho. Add an optional seconds argument for time sampling support. Build: Use C++11 for OSX Mavericks. Define ALEMBIC_LIB_USES_BOOST to accomodate python bindings. Use LIBPYTHON_VERSION to determine which python to use. ##-***************************************************************************** 2013-12-17, Alembic 1.5.3 Hello Alembic users, thanks to your feedback and reports we have a few bug fixes and enhancements. API, Ogawa: Don't open extra filestreams until they are needed. Maya, AbcImport: Fix for issue 251, if connections to the immediate children of the archive fail warn about it. Relax naming constraints on connection so that if the namespace is different between the Maya scene and the Alembic archive, they can still connect. Specifying a Maya node to -connect which doesn't match any of the children of the immediate root of the archive, try and connect below that specified Maya node. Python: cask: Fix for issue 318, make sure the archive gets released properly. abcview: Fix bug where animated normals weren't being updated for display. ##-***************************************************************************** 2013-12-6, Alembic 1.5.2 Hello Alembic users, thanks to your feedback and contributions we have another collection of bug fixes and enhancements to the API. API: Add Nurbs Curves support to I/OCurves, also addresses Issue 249. Most reference implementations have not yet been updated to support it. Add SetSourceName, GetSourceName, SetIsUV, isUV utility functions and setUVSourceName member function on OPolyMeshSchema and OSubDSchema. Don't assert in TimeSampling::getNearIndex if the floor index and the ceil index are the same. Address several clang compile warnings. Part of Issue 322. AbcCoreHDF5 and AbcCoreOgawa: Fix reported thread-safety issues. Python bindings: Fix for issue 326. "error: control reaches end of non-void function" in PyIArchive Add Nurbs Curves support to I/OCurves. Note: The expected number of knots per curve is the number of vertices in the curve plus the order of the curve. Add SetSourceName, GetSourceName, SetIsUV, isUV utility functions and setUVSourceName member function on OPolyMeshSchema and OSubDSchema. AbcOpenGL: Fix for issue 324, clamp values instead of asserting. Misc Tools: AbcStitcher: Support stitching Nurbs curves. Fix bug where the output file would only be HDF5. Fix bug where invalid metadata and name were used for leftover objects. Fix bug where top object was gotten before checking for archive validity. Add additional check and error message if the number of children nodes aren't the same between the IObjects from different archives. AbcTree: Rename variable to fix shadow warning on some compilers. Issue 320. Windows compatibility fix, S_ISDIR doesn't exist. AbcLs: Windows compatibility fix, S_ISDIR doesn't exist. Fix the way certain scalar properties print. ##-***************************************************************************** 2013-9-18, Alembic 1.5.1 Hello Alembic users, thanks to your feedback we have another collection of small but useful bug fixes and enhancements to the API, some of the example tools, and the Maya plugins. API: IXform/OXform: Make default identity xforms use even less disk space. Fix for Issue 313: IXformSchema::getInheritsXforms() crash with no samples Python bindings: Fix for Issue 308: ILightSchema.getCameraSchema() segfaults when no cameras are available Maya: AbcImport: Fix for Issue 311: properly set SubD creases, corners, and holes when the geometry is animated Fix for Issue 312: AbcImport doesn't accept long names when filtering AbcExport: Ogawa is now written out by default. (when the -dataformat flag isn't specified) Multiple frame ranges can be specified for more control over the samples exported. -preRoll flag was added for specified frame ranges that you want evaluated but not exported. Misc Tools: AbcLs - fix bugs, added new flag -s to view the size of a scalar or array property, -t for printing time info of the archive and the time a sample index of a property corresponds to. -f prints out the frame assuming 24fps. AbcView - tweaked docs, lots of bug fixes, better camera support prman Procedural - Fix for Issue 314: subdiv tags could become corrupted. ##-***************************************************************************** 2013-7-22, Alembic 1.5.0 Hello Alembic users, we are pleased to announce the official release of a new data back end for Alembic, codenamed Ogawa with improved write, read, and especially multi-threaded read performance. Here are some improvements we are seeing with this version: 1) File sizes are on average 5-15% smaller. Scenes with many small objects should see even greater reductions. 2) Single-threaded reads average around 4x faster 3) Multi-threaded reads can improve by 25x (relative to the same operations in the existing HDF5 back-end) on 8 core systems. We are maintaining backwards compatibility, and you will be able to continue to read and write Alembic files backed by HDF5. Other library features added: Support for explicit hierarchical deduplication. (OObject::addChildInstance) Hierarchical hash keys added to objects, making it easier to compare sub-graphs of various archives. (IObject::getPropertiesHash, IObject::getChildrenHash) Add AbcCoreFactory::IFactory class which is a convenience class for determining whether an archive is backed by HDF5 or Ogawa and returning a properly instantiated IArchive. All of the readers in the repository have been updated to use this. Python bindings have been extended to support the new features above. New utility: abcls this utility is meant to behave like ls or h5ls and offers an inexpensive way to explore your object and property hierarchies. Bug fixes: ICamera: Getting the film back xform channels needs to be done by index. Animated film back data wasn't being reflected in isConstant. Offset data should be applied after the filmback matrix. AbcExport: preScale, and postScale film back xform should be 1.0/scale. ##-***************************************************************************** 2013-4-11, Alembic 1.1.5 Hello Alembic users, thanks to your feedback we have another collection of small but useful bug fixes and performance enhancements for the Maya plugins. AbcExport: Improve the performance of util::isAnimated. If MFnIkJoint's Scale Compensate is off, [IS] is ignored otherwise multiply it after [T]. [IS] is actually the inverse of the inverseScale plug. Fixed const related error caught by Microsoft Visual Studio 9.0 compiler. AbcImport: Use createPoint and createColor for MFnNumericAttribute when appropriate. ##-***************************************************************************** 2013-03-25, Alembic 1.1.4 Hello Alembic users, thanks to your feedback we have another collection of small but useful and important bug fixes. Fix several multi-platform issues to making compiling in Windows and OSX easier. PyAlembic: Fix typo XformSample::getZRotation should be XformSample::getScale. AbcImport: Directly set the string plug, as the default value is not saved to the Maya file and thus is not restored. AbcExport/AbcImport: Fix bug where the conversion from shutter open, shutter close to shutter angle was being improperly scaled. ##-***************************************************************************** 2013-02-11, Alembic 1.1.3 Hello Alembic users, thanks to your feedback we have another collection of useful features and bug fixes. Alembic library: Add missing setTimeSampling member function to OCurves and ONuPatch. (Issue 295) Record the max number of samples written for various TimeSampling at the archive level, and provide a utility function for getting the start and end time of the archive using this data. (Issue 301) Propogate the Error handling policy better. Add Box2(s,i,f,d) array properties to match scalar properties. INuPatch getTopologyVariance wasn't correctly taking into account animated weights. IsAncestorVisible utility function was returning the wrong value. TimeSamplingType now allows for some floating point imprecision during comparison. (Issue 301) Add isStandardName and makeStandardName convenience functions. - These functions offer plugin writers an easy way to get multi-application name compliance. They help you convert any special characters your application supports into a set universally accepted characters. Add AbcOpenGL library which is based on the draw code from SimpleAbcViewer. Python: Add PyAbcOpenGL bindings. Fix segfault with invalid getProperty index/name Add getProperty to OCompoundProperty Add getKey to IArrayProperty - This is the preferred way to get the alembic hash of a property. Previously you needed to build the a hash by marshalling and serializing the data in python which is slooow. Add getMaxNumSamplesForTimeSamplingIndex to IArchive. Add high level Python API named "cask" built on top of the Alembic Python bindings. - This was developed to simplify scripting of alembic files in Python. - It is designed to be easy to use and "Pythonic". For example it gives you a dictionary style interface to objects and properties. - It is an abstraction on top of alembic which allows you to create mutable objects. This means scripters are not forced to use the separated, immutable input and output core alembic objects. - We will host documentation on docs.alembic.io shortly but for now please convert the cask.rst file in python/examples/cask/doc to read the docs and see examples. Add abcview which uses PyQt and PyAbcOpenGL - This tool is perfect for debugging alembic caches. It offers Katana- style, lazy-UI hierarchy traversal and a script editor to do more in-depth object and property queries using the Python bindings. SimpleAbcView is embedded into the application for easy reference. Bootstrap and CMake: Fix boost configuration if you are not building pyalembic. (Issue 296) Eliminate many warnings when compiling with Visual Studio 10. (Issue 294) Improve many of our CMakeLists.txt so that you can use Cmake directly instead of having to go through the bootstrap. Better Windows compliance. (Look for further improvements over the next releases). Maya: AbcExport bounding box calculation for the entire archive is much more efficient and is especially noticeable when calculating bounds on deep hierarchies. Add identifyFile and haveNamespaceSupport to AlembicImportFileTranslator. Fix bug where the AlembicImportFileTranslator could not be unloaded properly. Arnold Procedural: Fix bug with multiple samples potentially being added for uvlist. Initialize makeInstance on creation. Add instanced nodes to the list of createdNodes. Utilities: Add abctree which walks the entire hierarchy and prints out the names of objects. ##-***************************************************************************** 2012-10-17, Alembic 1.1.2 Hello Alembic users, thanks to your feedback we have another collection of small but useful features and bug fixes. New features: Maya AbcImport: Added inclusive and exclusive filtering support to allow selective importing of cache objects via regex matches. Added file translator support. Alembic caches can now be opened directly and imported as Maya references. Facesets now get imported as Maya facesets instead of an integer array attribute. Maya AbcExport: Write out curves with a basis of b-spline and repeat first and last points twice (if they aren't repeated) if we have a cubic open curve. Support exporting Maya facesets with the -wfs/-writefacets flag. Add -ef/-eulerFilter flag which euler filters samples to rotate, rotate axis, and joint orient. Update -sn/-stripNamespaces flag with an optional integer to only strip that number of namespaces. Remove boost usage. Core library: Add static emptySample() convenience function. Improve const correctness on most of the Abc and AbcGeom getter functions. Child bounds are no longer written and read via the schema's sample class, instead the child bounds property is directly exposed on the schema. Normals and UVs IGeomParams are no longer returned by reference. On Xforms, only write the .animChans data once if necessary. Bug fixes: Maya AbcImport: Clean up temporary trim curves when the trim operation fails for MFnNurbsSurface. ##-***************************************************************************** 2012-9-20, Alembic 1.1.1 Hello Alembic users, thanks to your feedback we have another collection of small but useful and important bug fixes. Bug fixes: Issue 291 Fix for some compile issues/warnings on Windows. Issue 292 Hash keys are being computed incorrectly on Windows. Some small CMake updates. Fixed typo in OSubD::setHoles ##-***************************************************************************** 2012-7-26, Alembic 1.1.0 Hello Alembic users. We are excited to announce another release of Alembic which contains many new features, bug fixes and performance improvements. What's new: - AbcCollections. Alembic now supports the concept of a collection. Sometimes people refer to collections as "groups" or "object sets" (as in Maya). - AbcMaterial. Alembic now supports the concept of a material. This is done by defining a schema for a material definition which can act as a standalone object or as supplemental data attached to another object. AbcMaterial also defines conventions and utilities for binding and resolving marterial assignments and overrides. We have not gone as far as defining what a material schema should actually contain (as we did with cameras); instead we allow you to define your own material "target" to allow all the many variations in material standards that exist today. However we have reserved the name "abc" for a target we will define at a later time; the hope is that this material target would become the standard for material interchange. - AbcLight. Alembic now supports the concept of a light. Light objects are distinct objects that contain both a camera and a material schema. The material on the light controls the shader parameters associated with the light and the camera can contain all relevant camera-like light information. - Python bindings. At long last the Alembic team has finally completed the python bindings to allow scripters to access the full power of the alembic c++ api. All the new features listed above as well as the layers Abc though AbcGeom are bound. The base bindings of typed data (including typed arrays) are pyimath types so if your program can natively create imath data types there is no performance penalty to convert to and from alembic types. - Performance optimization. When we profiled Alembic we found that, for some caches, a great deal of time was being spent in HDF5 functions that access groups and attributes by name. We now let you optionally write a side car datastructure within the HDF5 file that maps the HDF5 hierarchy to HDF5 object references which results in lookups that are much faster. You pay the price of a slight disk size increase and memory footprint. - Maya plugin updates. The ".userProperties" compound property that is available on most Alembic objects is now supported for both read and write with full support for animated values. Additional parameters have also been added to the AlembicNode to allow cache retiming along with support for loop, reverse and bounce. - Boost removal from the core. We are no longer dependent on boost to give us an implementation of a shared pointer (for example) so we were able to remove the dependency on boost while building the core library. Bug Fixes: Issue 171: OScalar and OArray Properties had a scoping issue when parented to the immediate child compound property of an OObject. Issue 245: IGeomParam would match to properties that aren't geom params. IArrayProperty is always considered a geom param with constant scope. Issue 253-255 Several bugs involved with the -rm flag on AbcImport have been fixed. Issue 263 AbcExport UV write fix, loop over all faces, not just the faces which have UVs. Issue 275 AddGeomToParamListBuilderAsFloat was calculating wrong boundary for the IV2fArrayProperty. Issue 280 Accomodate Unicode file names in AbcImport and AbcExport. Issue 285 AbcGeom/Basis.h was not including Alembic/Util/Foundation.h ##-***************************************************************************** 2012-2-14, Alembic 1.0.5 Bug fix release. Fix for issue 272. Core: String dimensions weren't being written correctly for string arrays when copying a previous sample. Correctness updates to "matches(..)" (data matching functions). Houdini plugin: Reverting frame - 1 change. Including a clear cache function. ##-***************************************************************************** 2012-1-12, Alembic 1.0.4 Hello, Alembic users, thanks to your feedback we have another collection of API additions and small but useful bug fixes. Some highlights: API: - Now supports raw reads, and reading as a different precision, for array properties via a new method getAs (). Currently strings, wstrings, and float16_t can not be read as any other type. - Added an optional velocity property to polymeshes, subds, nurbs, and curves. Velocity is considered to be in units per second. - Added a temporary work around for an HDF5 bug where parts of the file could become corrupt. This workaround always stores the HDF5 links in dense storage. This can lead to larger file sizes when you have a lot of IObjects. - Improved the performance on partial hierarchy traversal by deferring opening of an object's HDF5 group until truly needed. Renderman Procedural: - Added support for V3dGeomParam, P3dGeomParam, and BoolGeomParam Houdini SOP: - Dramatically increased the performance under Houdini 12 and pleasantly increased performance under 11.1. Maya AbcImport: - Don't interpolate when the time values closely match the ceiling value. - Don't create a new color set every time an animated color set is evaluated. - Interpolating non indexed color values would sometimes cause a crash. We welcome your comments on the discussion list. http://groups.google.com/group/alembic-discussion ##-***************************************************************************** 2011-11-11, Alembic 1.0.3 Hello, Alembic users, thanks to your feedback we have another collection of small but useful bug fixes to our plugins. Some highlights: Renderman Procedural: - Addition of Windows export information for ConvertParameters/Subdivide/Free - Fixed an uninitialized variable for -flipv - Fixed a string-related memory bug for declarations in ParamListBuilder (issue 241) - Addition of support for reading, caching and sharing argument strings from files. - Addition of support for restoring named resource blocks at specified paths or names for objects and facesets - Fixed support for getInheritsXforms in IXforms (issue 247) - Fixed CMake where it failed to find libprman.lib because of a typo (issue 229) Maya AbcImport: - Fixed compilation with Maya 2011 by adding an ifdef for the setDisplayColors(true) call. (issue 244) - Fixed some issues with the -connect option. Transforms weren't being properly cleared when connection. Maya AbcExport: - Change for FBIK joints, there isn't always a connection to translate or scale (like rotate for IK joints). We now treat them like they are animated. - Return an error if the file can't be written to. - The full -renderableOnly flag was not properly being detected (issue 252) We welcome your comments on the discussion list. http://groups.google.com/group/alembic-discussion ##-***************************************************************************** 2011-10-12, Alembic 1.0.2 Hello, Alembic users, thanks to your feedback we have another collection of small but useful bug fixes and a couple of new flags for some of our plugins. Some highlights: - In Maya don't flip V when reading and writing UVs. (AbcExport and AbcImport) - Add a flag (-flipv) to the prman Procedural to flip V when necessary. - Add a flag (-wcs / -writeColorSets) to AbcExport to write out color sets and restore them on AbcImport. - In AbcExport the -renderableOnly flag was doing the opposite of what it was supposed to do. - Fix bug in SimpleAbcViewer where XformSchema::getInheritsXforms() was not being respected. - Fix bug in AbcStitcher to prevent a segfault. We welcome your comments on the discussion list. http://groups.google.com/group/alembic-discussion ##-***************************************************************************** 2011-09-15, Alembic 1.0.1 Hello, Alembic users, we've gotten great feedback from the community and with their help we've created this collection of small but useful bug fixes. Some highlights: - A collection of useful bug fixes in the Maya AbcExport and AbcImport plugins - The renderman procedural has some small bug fixes, e.g. fixes related to arbitrary geometric parameters As always, any files generated by either Alembic 1.0.0 or Alembic 1.0.1 will interoperate. If you are working in Maya we encourage you to look at this update. The complete code changes for this release can be examined here: http://codereview.appspot.com/4978066/ We welcome your comments on the discussion list. http://groups.google.com/group/alembic-discussion ##-***************************************************************************** 2011-08-09, Alembic 1.0 Hello, Alembic users, welcome to our first gold release of Alembic. The complete code changes for this release can be examined here: http://codereview.appspot.com/4819067/ Some highlights: - Addition of the Arnold procedural. - Removal of some things that weren't Alembic related (GLUtil) - Addition of a python unit test suite for AbcExport and AbcImport. - Lots of Houdini SOP improvements. - Cleanup of many compiler warnings. This initial 1.0 version can now be used for critical, deadline-driven production work. Also as usual, feedback and questions are welcome! The main discussion list is low-traffic, but anyone can sign up and participate: http://groups.google.com/group/alembic-discussion ##-***************************************************************************** 2011-06-28, Alembic 1.0rc1 Hello, Alembic users, welcome to the latest beta version of Alembic. As we close in on a 1.0 release, we hope the API and file format are now stable and fully forwards-compatible. We consider these to be at a first "Release Candidate" stage. (note that this doesn't yet apply to the application-specific reference implementations). As with all pre-release software, we can't guarantee that changes won't occur between now and a full 1.0 release. This release is mostly a bugfix and cleanup release. We've improved the build support for Windows and OS X, as well as conformed the definitions of the Curves and NuPatch types more closely to the RI spec. Those changes, though, do mean that Curves and NuPatch geometry written out with previous releases will not be recognized with this release. The complete code changes for this release can be examined here: http://codereview.appspot.com/4662068 Some highlights: - The flags and arguments for the AbcExport Maya plugin have been updated based on feedback from the community, and to be more Maya-idiomatic. You can see all the arguments supported by entering "AbcExport -h" in the script editor. - The Makefile setup for the AlembicIn Houdini SOP is greatly simplified, though still not fully integrated with Alembic's CMake setup. - The PRMan procedural now supports the Points, NuPatch, Curves, and FaceSet types from AbcGeom. One other important thing to note: previous releases of Alembic did not require any of the compiled Boost libraries, but going forward, Alembic requires libboost_thread. Although this is our initial 1.0 release candidate, it should still be considered pre-release software, and should not be used for critical, deadline- driven production work. Also as usual, feedback and questions are welcome! The main discussion list is low-traffic, but anyone can sign up and participate: http://groups.google.com/group/alembic-discussion As always, discussion is welcome on the discussion list. ##-***************************************************************************** 2011-05-18, Alembic 0.9.3: The biggest news in this release is what we hope is the complete set of geometric types for ALembic 1.0, which includes curves (fashioned after RiCurves), nurbs surfaces, facesets in polygons and subds, and a camera definition. See http://code.google.com/p/alembic/wiki/Alembic_Geometric_Types for a complete list. The complete code changes for this release can be examined here: http://codereview.appspot.com/4517085 Some highlights: - There is now a single class for expression transforms. Preivously we had both SimpleXform and Xform objects for expressing transformation. The new unified Xform class can be used more simply than the old Xform class, while retaining the expressivity of the original. - We have experimental support for building Alembic on Windows. Details for how to perform the build can found in build/Windows/README.txt and build/Windows/WindowsBuildSteps.html - We've changed the API in a couple places, most notably, in the way instances of the class class Alembic::AbcCoreAbstract::TimeSampling are stored and referenced. - There is a reference Houdini SOP that can read an entire Alembic archive or a subtree of an archive with the option to bake in transformations. As such, it could also serve as the "leaf" node for an import process which rebuilt the full transformation hierarchy within Houdini. The intention is to pair this with a CHOP (not slated for inclusion this round) which extracts transformation channels from the archive. However, it is not yet integrated into the Alembic build infrastructure, so compiling it may take some work. As this is still a 0.9 release, it is still to be considered Beta, and should not be used for critical, deadline-driven production work. Also as usual, feedback and questions are welcome! The main discussion list is low-traffic, but anyone can sign up and participate: http://groups.google.com/group/alembic-discussion As always, discussion is welcome on the discussion list. ##-***************************************************************************** 2011-02-17, Alembic 0.9.2: This is somewhere between a major and minor update. Numerous bugs have been fixed, some new functionality has been introduced, and reference Maya plugins for import and export have been added. The code changes can be examined here: http://codereview.appspot.com/4160045/ Some highlights in functionality: - Maya export and import plugins are in the top-level "maya" directory. - In the top-level "python" directory is the beginning of Python bindings using Boost.Python. This effort is currently incomplete, but with these bindings, the structure of an Alembic Archive can be examined. - UVs on PolyMeshes and SubD meshes, as well as Normals on PolyMeshes, are included in their definition, and can be written and read as indexed arrays or expanded, non-indexed arrays, with automatic interconversion between the two representations. As this is still a 0.9 release, it is still to be considered Beta, and should not be used for critical, deadline-driven production work. Also as usual, feedback and questions are welcome! The main discussion list is low-traffic, but anyone can sign up and participate: http://groups.google.com/group/alembic-discussion As always, discussion is welcome on the discussion list: ##-***************************************************************************** 2010-12-13, Alembic 0.9.1: Just a minor update to enable Alembic on 32-bit systems, along with getting the code in examples/bin/AbcEcho reasonably working. 2010-12-08, Alembic 0.9.1: The main things in this release are the addition of a Renderman procedural plugin, and a bunch of bug fixes. The example Maya exporter (AlembicSimpleAbcExport) can be used to create an Alembic file from a Maya scene, and that Alembic file can be read by the Renderman plugin to create images, which means that an end-to-end workflow can be achieved. A complete overview of the changes to the code is here: http://codereview.appspot.com/3427045 A summary of the bugs fixed in this change: http://code.google.com/p/alembic/issues/detail?id=71 An internal implementation detail that fixed an issue where files created by the AlembicSimpleAbcExport Maya plugin were invalid. http://code.google.com/p/alembic/issues/detail?id=118 Another internal implementation bugfix that ensured that certain properties of a subdivision surface were properly animatable. http://code.google.com/p/alembic/issues/detail?id=17 Method to return a Property's parent Object simply did not work. http://code.google.com/p/alembic/issues/detail?id=121 Methods to determine high-level type now more flexible and correct. http://code.google.com/p/alembic/issues/detail?id=7 Build system improvement; now behaves better when trying to find the Boost headers and libraries. http://code.google.com/p/alembic/issues/detail?id=13 A consequence of the bug that was fixed in issue 71. http://code.google.com/p/alembic/issues/detail?id=123 Alembic was not reading all the required data from an ISimpleXform. In progress, we have: http://code.google.com/p/alembic/issues/detail?id=102 This is an arbitrary transform "stack" type, roughly equivalent to Renderman's transformation model. It has per-operation hints that allow it to be recognized as a transform and mapped directly to another application's transformation model. It can also be read and written as a regular 4x4 matrix. ##-***************************************************************************** alembic-1.8.9/README.txt000066400000000000000000000060561507001531700146310ustar00rootroot00000000000000------------------------------------------------------------------------------- - Alembic - - Copyright 2009-2021 Sony Pictures Imageworks, Inc. and - Industrial Light and Magic, a division of Lucasfilm Entertainment Company Ltd. ------------------------------------------------------------------------------- Installation instructions for Alembic 0) Before Alembic can be built, you will need to satisfy its external dependencies: Required: CMake (3.13+) www.cmake.org C++ compiler that supports C++11 Imath 3 https://github.com/AcademySoftwareFoundation/Imath Optional: HDF5 (1.8.9) www.hdfgroup.org/HDF5 Boost (1.55+) www.boost.org (to build the python bindings) PyImath 3 https://github.com/AcademySoftwareFoundation/Imath (to build the python bindings) Arnold (3.3+) Pixar PRMan (15.x) Autodesk Maya (2012+) Note that the versions given parenthetically above are minimum-tested versions. You may have good luck with later or earlier versions, but this is what we've been building Alembic against. They may be installed in their default system locations (typically somewhere under /usr/local), or some other centralized directory at your discretion; it's best not to install your dependencies under the Alembic source root. 1) Clone the Alembic repo source into your desired source root: $ git clone https://github.com/alembic/alembic [] This will create your source root directory that contains the Alembic source code. 2) Run the cmake command. You should create a separate build root and pass the source root to cmake: $ cd $ cmake [OPTIONS] Some examples of OPTIONS you may want or need to use include: -DALEMBIC_SHARED_LIBS=OFF If you want the primary Alembic library to be built as a static library, instead of a dynamic one. -DUSE_HDF5=ON Specify this if you want to include optional HDF5 support. -DHDF_ROOT=HDF5Path may need to be specified if HDF5 is not installed in a standard location. -DUSE_MAYA=ON If you want to build AbcExport and AbcImport. -DMAYA_ROOT=MayaPath may need to be specified to point at a specific installation of Maya. -G "Visual Studio 15 2017 Win64" If you want to create the project file for the 64 bit build of Alembic with the Visual Studio 2017 Community Edition. -DCMAKE_INSTALL_PREFIX=customPath If you want to install the Alembic into an arbitrary location. -DUSE_PYALEMBIC=ON Whether you want to build the boost python bindings for Alembic. -DDOCS_PATH=customDocPath If you have Doxygen installed this will create and install the doxygen generated doc (WIP) to customDocPath when you run: cmake doxygen 3) To build: cmake -build . 4) To test: ctest Note: On Windows you may need to add the path to your Alembic dlls. PATH=%PATH%;location of Alembic dlls (and Imath if not in a standard place) If you get stuck, contact us on the alembic-discussion mailing list. You can view the mailing list archives and join the mailing list: http://groups.google.com/group/alembic-discussion alembic-1.8.9/arnold/000077500000000000000000000000001507001531700144035ustar00rootroot00000000000000alembic-1.8.9/arnold/CMakeLists.txt000066400000000000000000000037071507001531700171520ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2011, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Sony Pictures Imageworks, nor ## Industrial Light & Magic, nor the names of their contributors may be used ## to endorse or promote products derived from this software without specific ## prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** IF( ${ALEMBIC_ARNOLD_FOUND} ) ADD_SUBDIRECTORY( Tests ) ADD_SUBDIRECTORY( Procedural ) ENDIF() alembic-1.8.9/arnold/Procedural/000077500000000000000000000000001507001531700165035ustar00rootroot00000000000000alembic-1.8.9/arnold/Procedural/ArbGeomParams.cpp000066400000000000000000000334451507001531700217000ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include "ArbGeomParams.h" #include std::string GetArnoldTypeString( GeometryScope scope, int arnoldAPIType) { std::ostringstream buffer; switch (scope) { case kUniformScope: buffer << "uniform"; break; case kVaryingScope: case kVertexScope: buffer << "varying"; break; case kFacevaryingScope: return ""; //arnold doesn't support facevarying user-data case kConstantScope: default: buffer << "constant"; } buffer << " "; switch ( arnoldAPIType ) { case AI_TYPE_INT: buffer << "INT"; break; case AI_TYPE_FLOAT: buffer << "FLOAT"; break; case AI_TYPE_STRING: buffer << "STRING"; break; case AI_TYPE_RGB: buffer << "RGB"; break; case AI_TYPE_RGBA: buffer << "RGBA"; break; case AI_TYPE_POINT: buffer << "POINT"; break; case AI_TYPE_VECTOR: buffer << "VECTOR"; break; case AI_TYPE_POINT2: buffer << "POINT2"; break; case AI_TYPE_MATRIX: buffer << "MATRIX"; break; default: // For now, only support the above types return ""; } return buffer.str(); } //-***************************************************************************** template void AddArbitraryGeomParam( ICompoundProperty & parent, const PropertyHeader &propHeader, ISampleSelector &sampleSelector, AtNode * primNode, int arnoldAPIType) { T param( parent, propHeader.getName() ); if ( !param.valid() ) { //TODO error message? return; } std::string declStr = GetArnoldTypeString( param.getScope(), arnoldAPIType ); if ( declStr.empty() ) { return; } // TODO For now, don't support user-defined arrays. // It's reasonable to support these for kConstantScope if ( param.getArrayExtent() > 1 ) { return; } if ( !AiNodeDeclare( primNode, param.getName().c_str(), declStr.c_str() ) ) { //TODO, AiWarning return; } if ( param.getScope() == kConstantScope || param.getScope() == kUnknownScope) { //Set scalars directly based on arnoldAPIType since we're //not yet support array types here typename T::prop_type::sample_ptr_type valueSample = param.getExpandedValue( sampleSelector ).getVals(); switch ( arnoldAPIType ) { case AI_TYPE_INT: AiNodeSetInt( primNode, param.getName().c_str(), reinterpret_cast( valueSample->get() )[0] ); break; case AI_TYPE_FLOAT: AiNodeSetFlt( primNode, param.getName().c_str(), reinterpret_cast( valueSample->get() )[0] ); break; case AI_TYPE_STRING: AiNodeSetStr( primNode, param.getName().c_str(), reinterpret_cast( valueSample->get() )[0].c_str() ); break; case AI_TYPE_RGB: { const float32_t * data = reinterpret_cast( valueSample->get() ); AiNodeSetRGB( primNode, param.getName().c_str(), data[0], data[1], data[2]); break; } case AI_TYPE_RGBA: { const float32_t * data = reinterpret_cast( valueSample->get() ); AiNodeSetRGBA( primNode, param.getName().c_str(), data[0], data[1], data[2], data[3]); break; } case AI_TYPE_POINT: { const float32_t * data = reinterpret_cast( valueSample->get() ); AiNodeSetPnt( primNode, param.getName().c_str(), data[0], data[1], data[2]); break; } case AI_TYPE_VECTOR: { const float32_t * data = reinterpret_cast( valueSample->get() ); AiNodeSetVec( primNode, param.getName().c_str(), data[0], data[1], data[2] ); break; } case AI_TYPE_POINT2: { const float32_t * data = reinterpret_cast( valueSample->get() ); AiNodeSetPnt2( primNode, param.getName().c_str(), data[0], data[1] ); break; } case AI_TYPE_MATRIX: { const float32_t * data = reinterpret_cast( valueSample->get() ); AtMatrix m; for ( size_t i = 0; i < 16; ++i ) { *((&m[0][0])+i) = data[i]; } AiNodeSetMatrix( primNode, param.getName().c_str(), m); break; } default: // For now, only support the above types break; } } else { // Always set arrays for other scopes typename T::prop_type::sample_ptr_type valueSample = param.getExpandedValue( sampleSelector ).getVals(); AiNodeSetArray( primNode, param.getName().c_str(), ArrayConvert( valueSample->size(), 1, arnoldAPIType, (void *) valueSample->get() ) ); } } //-***************************************************************************** void AddArbitraryStringGeomParam( ICompoundProperty & parent, const PropertyHeader &propHeader, ISampleSelector &sampleSelector, AtNode * primNode) { IStringGeomParam param( parent, propHeader.getName() ); if ( !param.valid() ) { //TODO error message? return; } std::string declStr = GetArnoldTypeString( param.getScope(), AI_TYPE_STRING ); if ( declStr.empty() ) { return; } // TODO, remove this restriction and support arrays for constant values if ( param.getArrayExtent() > 1 ) { return; } if ( !AiNodeDeclare( primNode, param.getName().c_str(), declStr.c_str() ) ) { //TODO, AiWarning return; } IStringGeomParam::prop_type::sample_ptr_type valueSample = param.getExpandedValue( sampleSelector ).getVals(); if ( param.getScope() == kConstantScope || param.getScope() == kUnknownScope) { AiNodeSetStr( primNode, param.getName().c_str(), reinterpret_cast( valueSample->get() )[0].c_str() ); } else { std::vector strPtrs; strPtrs.reserve( valueSample->size() ); for ( size_t i = 0; i < valueSample->size(); ++i ) { strPtrs.push_back( valueSample->get()[i].c_str() ); } AiNodeSetArray( primNode, param.getName().c_str(), ArrayConvert( valueSample->size(), 1, AI_TYPE_STRING, (void *) &strPtrs[0] ) ); } } //-***************************************************************************** //UserDefDeclare(node, name.c_str(), userType.c_str())) continue; //SetUserData(node, name.c_str(), dataSize, apiType, dataStart); void AddArbitraryGeomParams( ICompoundProperty &parent, ISampleSelector &sampleSelector, AtNode * primNode, const std::set * excludeNames ) { if ( primNode == NULL || !parent.valid() ) { return; } for ( size_t i = 0; i < parent.getNumProperties(); ++i ) { const PropertyHeader &propHeader = parent.getPropertyHeader( i ); const std::string &propName = propHeader.getName(); if (propName.empty() || ( excludeNames && excludeNames->find( propName ) != excludeNames->end() ) ) { continue; } if ( IFloatGeomParam::matches( propHeader ) ) { AddArbitraryGeomParam( parent, propHeader, sampleSelector, primNode, AI_TYPE_FLOAT); } else if ( IInt32GeomParam::matches( propHeader ) ) { AddArbitraryGeomParam( parent, propHeader, sampleSelector, primNode, AI_TYPE_INT); } else if ( IStringGeomParam::matches( propHeader ) ) { AddArbitraryStringGeomParam( parent, propHeader, sampleSelector, primNode); } else if ( IV2fGeomParam::matches( propHeader ) ) { AddArbitraryGeomParam( parent, propHeader, sampleSelector, primNode, AI_TYPE_POINT2); } else if ( IV3fGeomParam::matches( propHeader ) ) { AddArbitraryGeomParam( parent, propHeader, sampleSelector, primNode, AI_TYPE_VECTOR); } else if ( IP3fGeomParam::matches( propHeader ) ) { AddArbitraryGeomParam( parent, propHeader, sampleSelector, primNode, AI_TYPE_POINT); } else if ( IN3fGeomParam::matches( propHeader ) ) { AddArbitraryGeomParam( parent, propHeader, sampleSelector, primNode, AI_TYPE_VECTOR); } else if ( IC3fGeomParam::matches( propHeader ) ) { AddArbitraryGeomParam( parent, propHeader, sampleSelector, primNode, AI_TYPE_RGB); } else if ( IC4fGeomParam::matches( propHeader ) ) { AddArbitraryGeomParam( parent, propHeader, sampleSelector, primNode, AI_TYPE_RGBA); } if ( IM44fGeomParam::matches( propHeader ) ) { AddArbitraryGeomParam( parent, propHeader, sampleSelector, primNode, AI_TYPE_MATRIX); } } } alembic-1.8.9/arnold/Procedural/ArbGeomParams.h000066400000000000000000000051451507001531700213410ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Arnold_ArbGeomParams_h #define Alembic_Arnold_ArbGeomParams_h #include #include using namespace Alembic::AbcGeom; void AddArbitraryGeomParams( ICompoundProperty &parent, ISampleSelector &sampleSelector, AtNode * primNode, const std::set * excludeNames = NULL ); inline AtArray* ArrayConvert(AtUInt32 nelements, AtByte nkeys, AtByte type, void* data) { #if AI_VERSION_ARCH_NUM < 4 return AiArrayConvert(nelements, nkeys, type, data, TRUE); #else // Arnold 4.x essentially hardcodes the last param to true return AiArrayConvert(nelements, nkeys, type, data); #endif } #endif alembic-1.8.9/arnold/Procedural/CMakeLists.txt000066400000000000000000000046721507001531700212540ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, Industrial Light & Magic, ## a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** PROJECT( ALEMBIC_ARNOLD_PROCEDURAL_MODULE ) IF( ${ALEMBIC_ARNOLD_FOUND} ) SET( H_FILES ArbGeomParams.h PathUtil.h ProcArgs.h SampleUtil.h WriteGeo.h ) SET( CXX_FILES ArbGeomParams.cpp PathUtil.cpp ProcArgs.cpp ProcMain.cpp SampleUtil.cpp WriteGeo.cpp ) ADD_ARNOLD_CXX_PLUGIN( AlembicArnoldProcedural ProcMain.cpp ${H_FILES} ${CXX_FILES} ) TARGET_LINK_LIBRARIES( AlembicArnoldProcedural Alembic::Alembic) set_target_properties(AlembicArnoldProcedural PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) INSTALL ( TARGETS AlembicArnoldProcedural DESTINATION arnold/procedurals ) ENDIF() alembic-1.8.9/arnold/Procedural/PathUtil.cpp000066400000000000000000000046401507001531700207450ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include "PathUtil.h" #include //-***************************************************************************** void TokenizePath( const std::string &path, std::vector &result ) { typedef boost::char_separator Separator; typedef boost::tokenizer Tokenizer; Tokenizer tokenizer( path, Separator( "/" ) ); for ( Tokenizer::iterator iter = tokenizer.begin() ; iter != tokenizer.end() ; ++iter ) { if ( (*iter).empty() ) { continue; } result.push_back( *iter ); } } alembic-1.8.9/arnold/Procedural/PathUtil.h000066400000000000000000000041011507001531700204020ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Prman_PathUtil_h #define Alembic_Prman_PathUtil_h #include typedef std::vector PathList; void TokenizePath( const std::string &path, PathList &result ); #endif alembic-1.8.9/arnold/Procedural/ProcArgs.cpp000066400000000000000000000221321507001531700207270ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include "ProcArgs.h" #include #include #include #include //-***************************************************************************** //INSERT YOUR OWN TOKENIZATION CODE AND STYLE HERE ProcArgs::ProcArgs( const char * paramStr ) : frame(0.0) , fps(24.0) , shutterOpen(0) , shutterClose(0) , excludeXform(false) , makeInstance(false) , subdIterations(0) , proceduralNode(0) { // TODO, grab the shutter a camera attached to AiUniverse if present typedef boost::char_separator Separator; typedef boost::tokenizer Tokenizer; std::vector tokens; std::string params( paramStr ); Tokenizer tokenizer( params, Separator(" ") ); for ( Tokenizer::iterator iter = tokenizer.begin(); iter != tokenizer.end() ; ++iter ) { if ( (*iter).empty() ) { continue; } tokens.push_back( *iter ); } for ( size_t i = 0; i < tokens.size(); ++i ) { std::string token = tokens[i]; std::transform( token.begin(), token.end(), token.begin(), ::tolower ); if ( token == "-frame" ) { ++i; if ( i < tokens.size() ) { frame = atof( tokens[i].c_str() ); } } else if ( token == "-fps" ) { ++i; if ( i < tokens.size() ) { fps = atof( tokens[i].c_str() ); } } else if ( token == "-shutteropen" ) { ++i; if ( i < tokens.size() ) { shutterOpen = atof( tokens[i].c_str() ); } } else if ( token == "-shutterclose" ) { ++i; if ( i < tokens.size() ) { shutterClose = atof( tokens[i].c_str() ); } } else if ( token == "-filename" ) { ++i; if ( i < tokens.size() ) { filename = tokens[i]; } } else if ( token == "-nameprefix" ) { ++i; if ( i < tokens.size() ) { nameprefix = tokens[i]; } } else if ( token == "-objectpath" ) { ++i; if ( i < tokens.size() ) { objectpath = tokens[i]; } } else if ( token == "-excludexform" ) { excludeXform = true; } else if ( token == "-subditerations" ) { ++i; if ( i < tokens.size() ) { subdIterations = atoi( tokens[i].c_str() ); } } else if ( token == "-makeinstance" ) { makeInstance = true; } } } void ProcArgs::usage() { std::cerr << "AlembicArnoldProcedural usage:" << std::endl; std::cerr << std::endl; std::cerr << "-filename /path/to/some/archive.abc" << std::endl; std::cerr << std::endl; std::cerr << "This is the only required argument. " "It has no default value." << std::endl; std::cerr << std::endl; std::cerr << "-frame 42" << std::endl; std::cerr << std::endl; std::cerr << "The frame number to load from within the archive. " "The default value is 0. This is combined with -fps to map " "to Alembic time units (double-precision seconds)."; std::cerr << std::endl; std::cerr << std::endl; std::cerr << "-fps 24" << std::endl; std::cerr << std::endl; std::cerr << "Combined with -frame above. The default value is 24.0."; std::cerr << std::endl; std::cerr << std::endl; std::cerr << "-shutteropen 0.0" << std::endl; std::cerr << "-shutterclose 0.5" << std::endl; std::cerr << std::endl; std::cerr << "These are frame-relative values which specify the shutter " "window. The procedural will include all samples present in " "the archive which are relevant to the shutter window. " "The default value of both is 0.0 (no motion blur)."; std::cerr << std::endl; std::cerr << std::endl; std::cerr << "-objectpath /assetroot/characters" << std::endl; std::cerr << std::endl; std::cerr << "If specified, only objects at or below the provided path " "(within the archive) will be emitted. When combined with " "-excludexform, this can also be used to load individual " "leaf locations within an externally defined hierarchy. Be " "aware that in that case, you'd need to set the \"matrix\" " "and \"inherit_xform\" parameters on the procedural node " "itself. If the path points to a single \"faceset\" object " "directly beneath a polymesh or subdivision mesh, it'll add " "a \"face_visibility\" user data array."; std::cerr << std::endl; std::cerr << std::endl; std::cerr << "-excludexform" << std::endl; std::cerr << std::endl; std::cerr << "If specified, the \"matrix\" parameter will not be set on " "the resulting primitive nodes." << std::endl; std::cerr << std::endl; std::cerr << "-subditerations 2" << std::endl; std::cerr << std::endl; std::cerr << "For AbcGeom::ISubD objects, this option specifies the " "\"subdiv_iterations\" value. It currently has no effect for " "other primitive types. The default value is 0."; std::cerr << std::endl; std::cerr << std::endl; std::cerr << "-nameprefix some_prefix__" << std::endl; std::cerr << std::endl; std::cerr << "Because node names are unique scene-wide in arnold, this " "allows you control potential name clashes when loading or " "instancing an archive (or multiple equivalently named " "archives) multiple times. The default name of each node is " "its full path within the alembic archive."; std::cerr << std::endl; std::cerr << std::endl; std::cerr << "-makeinstance" << std::endl; std::cerr << std::endl; std::cerr << "This behavior is disabled by default. If enabled, the " "procedural will attempt to identify identical primitives " "(using Alembic's per-array-property hash keys) and create " "corresponding \"ginstance\" nodes. Two primitives are " "considered equivalent if the keys of their relevant point " "position samples match along with any specified " "subdivision values. This works across multiple archives or " "invokations of the procedural. It currently does not write " "unique user data per instance but will likely do so " "automatically (when necessary) in a future release. " "The ray visibility of the source primitive will be set to " "AI_RAY_NONE and the \"ginstance\" node's will be set to " "that of the calling \"procedural\" node."; std::cerr << std::endl; } alembic-1.8.9/arnold/Procedural/ProcArgs.h000066400000000000000000000057341507001531700204050ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Arnold_ProcArgs_h #define Alembic_Arnold_ProcArgs_h #include #include #include //-***************************************************************************** struct ProcArgs { //constructor parses ProcArgs( const char * paramStr ); //copy constructor ProcArgs( const ProcArgs &rhs ) : filename( rhs.filename ) , nameprefix( rhs.nameprefix ) , objectpath( rhs.objectpath ) , frame( rhs.frame ) , fps( rhs.fps ) , shutterOpen( rhs.shutterOpen ) , shutterClose( rhs.shutterClose ) , excludeXform( rhs.excludeXform ) , makeInstance( rhs.makeInstance ) , subdIterations ( rhs.subdIterations ) , proceduralNode( rhs.proceduralNode ) {} //member variables std::string filename; std::string nameprefix; std::string objectpath; double frame; double fps; double shutterOpen; double shutterClose; bool excludeXform; bool makeInstance; int subdIterations; AtNode * proceduralNode; std::vector createdNodes; void usage(); }; #endif alembic-1.8.9/arnold/Procedural/ProcMain.cpp000066400000000000000000000253741507001531700207320ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2015, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include "ProcArgs.h" #include "PathUtil.h" #include "SampleUtil.h" #include "WriteGeo.h" #include #include namespace { using namespace Alembic::AbcGeom; void WalkObject( IObject parent, const ObjectHeader &ohead, ProcArgs &args, PathList::const_iterator I, PathList::const_iterator E, MatrixSampleMap * xformSamples) { //Accumulate transformation samples and pass along as an argument //to WalkObject IObject nextParentObject; std::auto_ptr concatenatedXformSamples; if ( IXform::matches( ohead ) ) { if ( args.excludeXform ) { nextParentObject = IObject( parent, ohead.getName() ); } else { IXform xform( parent, ohead.getName() ); IXformSchema &xs = xform.getSchema(); if ( xs.getNumOps() > 0 ) { TimeSamplingPtr ts = xs.getTimeSampling(); size_t numSamples = xs.getNumSamples(); SampleTimeSet sampleTimes; GetRelevantSampleTimes( args, ts, numSamples, sampleTimes, xformSamples); MatrixSampleMap localXformSamples; MatrixSampleMap * localXformSamplesToFill = 0; concatenatedXformSamples.reset(new MatrixSampleMap); if ( !xformSamples ) { // If we don't have parent xform samples, we can fill // in the map directly. localXformSamplesToFill = concatenatedXformSamples.get(); } else { //otherwise we need to fill in a temporary map localXformSamplesToFill = &localXformSamples; } for (SampleTimeSet::iterator I = sampleTimes.begin(); I != sampleTimes.end(); ++I) { XformSample sample = xform.getSchema().getValue( Abc::ISampleSelector(*I)); (*localXformSamplesToFill)[(*I)] = sample.getMatrix(); } if ( xformSamples ) { ConcatenateXformSamples(args, *xformSamples, localXformSamples, *concatenatedXformSamples.get()); } xformSamples = concatenatedXformSamples.get(); } nextParentObject = xform; } } else if ( ISubD::matches( ohead ) ) { std::string faceSetName; ISubD subd( parent, ohead.getName() ); //if we haven't reached the end of a specified -objectpath, //check to see if the next token is a faceset name. //If it is, send the name to ProcessSubD for addition of //"face_visibility" tags for the non-matching faces if ( I != E ) { if ( subd.getSchema().hasFaceSet( *I ) ) { faceSetName = *I; } } ProcessSubD( subd, args, xformSamples, faceSetName ); //if we found a matching faceset, don't traverse below if ( faceSetName.empty() ) { nextParentObject = subd; } } else if ( IPolyMesh::matches( ohead ) ) { std::string faceSetName; IPolyMesh polymesh( parent, ohead.getName() ); //if we haven't reached the end of a specified -objectpath, //check to see if the next token is a faceset name. //If it is, send the name to ProcessSubD for addition of //"face_visibility" tags for the non-matching faces if ( I != E ) { if ( polymesh.getSchema().hasFaceSet( *I ) ) { faceSetName = *I; } } ProcessPolyMesh( polymesh, args, xformSamples, faceSetName ); //if we found a matching faceset, don't traverse below if ( faceSetName.empty() ) { nextParentObject = polymesh; } } else if ( INuPatch::matches( ohead ) ) { INuPatch patch( parent, ohead.getName() ); // TODO ProcessNuPatch( patch, args ); nextParentObject = patch; } else if ( IPoints::matches( ohead ) ) { IPoints points( parent, ohead.getName() ); // TODO ProcessPoints( points, args ); nextParentObject = points; } else if ( ICurves::matches( ohead ) ) { ICurves curves( parent, ohead.getName() ); // TODO ProcessCurves( curves, args ); nextParentObject = curves; } else if ( IFaceSet::matches( ohead ) ) { //don't complain about discovering a faceset upon traversal } else { std::cerr << "could not determine type of " << ohead.getName() << std::endl; std::cerr << ohead.getName() << " has MetaData: " << ohead.getMetaData().serialize() << std::endl; nextParentObject = parent.getChild(ohead.getName()); } if ( nextParentObject.valid() ) { //std::cerr << nextParentObject.getFullName() << std::endl; if ( I == E ) { for ( size_t i = 0; i < nextParentObject.getNumChildren() ; ++i ) { WalkObject( nextParentObject, nextParentObject.getChildHeader( i ), args, I, E, xformSamples); } } else { const ObjectHeader *nextChildHeader = nextParentObject.getChildHeader( *I ); if ( nextChildHeader != NULL ) { WalkObject( nextParentObject, *nextChildHeader, args, I+1, E, xformSamples); } } } } //-************************************************************************* int ProcInit( struct AtNode *node, void **user_ptr ) { ProcArgs * args = new ProcArgs( AiNodeGetStr( node, "data" ) ); args->proceduralNode = node; *user_ptr = args; #if (AI_VERSION_ARCH_NUM == 3 && AI_VERSION_MAJOR_NUM < 3) || AI_VERSION_ARCH_NUM < 3 #error Arnold version 3.3+ required for AlembicArnoldProcedural #endif if (!AiCheckAPIVersion(AI_VERSION_ARCH, AI_VERSION_MAJOR, AI_VERSION_MINOR)) { std::cout << "AlembicArnoldProcedural compiled with arnold-" << AI_VERSION << " but is running with incompatible arnold-" << AiGetVersion(NULL, NULL, NULL, NULL) << std::endl; return 1; } if ( args->filename.empty() ) { args->usage(); return 1; } Alembic::AbcCoreFactory::IFactory factory; factory.setPolicy(ErrorHandler::kQuietNoopPolicy); IArchive archive = factory.getArchive( args->filename ); IObject root = archive.getTop(); PathList path; TokenizePath( args->objectpath, path ); try { if ( path.empty() ) //walk the entire scene { for ( size_t i = 0; i < root.getNumChildren(); ++i ) { WalkObject( root, root.getChildHeader(i), *args, path.end(), path.end(), 0 ); } } else //walk to a location + its children { PathList::const_iterator I = path.begin(); const ObjectHeader *nextChildHeader = root.getChildHeader( *I ); if ( nextChildHeader != NULL ) { WalkObject( root, *nextChildHeader, *args, I+1, path.end(), 0); } } } catch ( const std::exception &e ) { std::cerr << "exception thrown during ProcInit: " << e.what() << std::endl; } catch (...) { std::cerr << "exception thrown\n"; } return 1; } //-************************************************************************* int ProcCleanup( void *user_ptr ) { delete reinterpret_cast( user_ptr ); return 1; } //-************************************************************************* int ProcNumNodes( void *user_ptr ) { ProcArgs * args = reinterpret_cast( user_ptr ); return (int) args->createdNodes.size(); } //-************************************************************************* struct AtNode* ProcGetNode(void *user_ptr, int i) { ProcArgs * args = reinterpret_cast( user_ptr ); if ( i >= 0 && i < (int) args->createdNodes.size() ) { return args->createdNodes[i]; } return NULL; } } //end of anonymous namespace extern "C" { ALEMBIC_EXPORT int ProcLoader(AtProcVtable* api) { api->Init = ProcInit; api->Cleanup = ProcCleanup; api->NumNodes = ProcNumNodes; api->GetNode = ProcGetNode; strcpy(api->version, AI_VERSION); return 1; } } alembic-1.8.9/arnold/Procedural/README000066400000000000000000000050421507001531700173640ustar00rootroot00000000000000AlembicArnoldProcedural usage: -filename /path/to/some/archive.abc This is the only required argument. It has no default value. -frame 42 The frame number to load from within the archive. The default value is 0. This is combined with -fps to map to Alembic time units (double-precision seconds). -fps 24 Combined with -frame above. The default value is 24 -shutteropen 0.0 -shutterclose 0.5 These are frame-relative values which specify the shutter window. The procedural will include all samples present in the archive which are relevant to the shutter window. The default value of both is 0.0 (no motion blur). -objectpath /assetroot/characters If specified, only objects at or below the provided path (within the archive) will be emitted. When combined with -excludexform, this can also be used to load individual leaf locations within an externally defined hierarchy. Be aware that in that case, you'd need to set the "matrix" and "inherit_xform" parameters on the procedural node itself. If the path points to a single "faceset" object directly beneath a polymesh or subdivision mesh, it'll add a "face_visibility" user data array. -excludexform If specified, the "matrix" parameter will not be set on the resulting primitive nodes. -subditerations 2 For AbcGeom::ISubD objects, this option specifies the "subdiv_iterations" value. It currently has no effect for other primitive types. The default value is 0. -nameprefix some_prefix__ Because node names are unique scene-wide in arnold, this allows you control potential name clashes when loading or instancing an archive (or multiple equivalently named archives) multiple times. The default name of each node is its full path within the alembic archive. -makeinstance This behavior is disabled by default. If enabled, the procedural will attempt to identify identical primitives (using Alembic's per-array-property hash keys) and create corresponding "ginstance" nodes. Two primitives are considered equivalent if the keys of their relevant point position samples match along with any specified subdivision values. This works across multiple archives or invokations of the procedural. It currently does not write unique user data per instance but will likely do so automatically (when necessary) in a future release. The ray visibility of the source primitive will be set to AI_RAY_NONE and the "ginstance" node's will be set to that of the calling "procedural" node. STILL TO DO: -AbcGeom::IPoints -AbcGeom::ICurves -AbcGeom::INuPatch -AbcGeom::ICamera -automatic recognition of unique user data per-instance alembic-1.8.9/arnold/Procedural/SampleUtil.cpp000066400000000000000000000235311507001531700212720ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include "SampleUtil.h" #include #include #include #include #include //-***************************************************************************** void GetRelevantSampleTimes( ProcArgs &args, TimeSamplingPtr timeSampling, size_t numSamples, SampleTimeSet &output, MatrixSampleMap * inheritedSamples) { if ( numSamples < 2 ) { output.insert( 0.0 ); return; } chrono_t frameTime = args.frame / args.fps; chrono_t shutterOpenTime = ( args.frame + args.shutterOpen ) / args.fps; chrono_t shutterCloseTime = ( args.frame + args.shutterClose ) / args.fps; // For interpolating and concatenating samples, we need to consider // possible inherited sample times outside of our natural shutter range if (inheritedSamples && inheritedSamples->size() > 1) { shutterOpenTime = std::min(shutterOpenTime, inheritedSamples->begin()->first); shutterCloseTime = std::max(shutterCloseTime, inheritedSamples->rbegin()->first); } std::pair shutterOpenFloor = timeSampling->getFloorIndex( shutterOpenTime, numSamples ); std::pair shutterCloseCeil = timeSampling->getCeilIndex( shutterCloseTime, numSamples ); //TODO, what's a reasonable episilon? static const chrono_t epsilon = 1.0 / 10000.0; //check to see if our second sample is really the //floor that we want due to floating point slop //first make sure that we have at least two samples to work with if ( shutterOpenFloor.first < shutterCloseCeil.first ) { //if our open sample is less than open time, //look at the next index time if ( shutterOpenFloor.second < shutterOpenTime ) { chrono_t nextSampleTime = timeSampling->getSampleTime( shutterOpenFloor.first + 1 ); if ( fabs( nextSampleTime - shutterOpenTime ) < epsilon ) { shutterOpenFloor.first += 1; shutterOpenFloor.second = nextSampleTime; } } } for ( index_t i = shutterOpenFloor.first; i < shutterCloseCeil.first; ++i ) { output.insert( timeSampling->getSampleTime( i ) ); } //no samples above? put frame time in there and get out if ( output.size() == 0 ) { output.insert( frameTime ); return; } chrono_t lastSample = *(output.rbegin() ); //determine whether we need the extra sample at the end if ( ( fabs( lastSample - shutterCloseTime ) > epsilon ) && lastSample < shutterCloseTime ) { output.insert( shutterCloseCeil.second ); } } //-***************************************************************************** namespace { void DecomposeXForm( const Imath::M44d &mat, Imath::V3d &scale, Imath::V3d &shear, Imath::Quatd &rotation, Imath::V3d &translation ) { Imath::M44d mat_remainder(mat); // Extract Scale, Shear Imath::extractAndRemoveScalingAndShear(mat_remainder, scale, shear); // Extract translation translation.x = mat_remainder[3][0]; translation.y = mat_remainder[3][1]; translation.z = mat_remainder[3][2]; // Extract rotation rotation = extractQuat(mat_remainder); } M44d RecomposeXForm( const Imath::V3d &scale, const Imath::V3d &shear, const Imath::Quatd &rotation, const Imath::V3d &translation ) { Imath::M44d scale_mtx, shear_mtx, rotation_mtx, translation_mtx; scale_mtx.setScale(scale); shear_mtx.setShear(shear); rotation_mtx = rotation.toMatrix44(); translation_mtx.setTranslation(translation); return scale_mtx * shear_mtx * rotation_mtx * translation_mtx; } // when amt is 0, a is returned inline double lerp(double a, double b, double amt) { return (a + (b-a)*amt); } Imath::V3d lerp(const Imath::V3d &a, const Imath::V3d &b, double amt) { return Imath::V3d(lerp(a[0], b[0], amt), lerp(a[1], b[1], amt), lerp(a[2], b[2], amt)); } M44d GetNaturalOrInterpolatedSampleForTime(const MatrixSampleMap & samples, Abc::chrono_t sampleTime) { MatrixSampleMap::const_iterator I = samples.find(sampleTime); if (I != samples.end()) { return (*I).second; } if (samples.empty()) { return M44d(); } if (samples.size() == 1) { return samples.begin()->second; } if (sampleTime <= samples.begin()->first) { return samples.begin()->second; } if (sampleTime >= samples.rbegin()->first) { return samples.rbegin()->second; } //find the floor and ceiling samples and interpolate Abc::chrono_t lTime = samples.begin()->first; Abc::chrono_t rTime = samples.rbegin()->first; for (MatrixSampleMap::const_iterator I = samples.begin(); I != samples.end(); ++I) { Abc::chrono_t testSampleTime= (*I).first; if (testSampleTime > lTime && testSampleTime <= sampleTime) { lTime = testSampleTime; } if (testSampleTime > rTime && testSampleTime >= sampleTime) { rTime = testSampleTime; } } M44d mtx_l; M44d mtx_r; { MatrixSampleMap::const_iterator I; I = samples.find(lTime); if (I != samples.end()) { mtx_l = (*I).second; } I = samples.find(rTime); if (I != samples.end()) { mtx_r = (*I).second; } } Imath::V3d s_l,s_r,h_l,h_r,t_l,t_r; Imath::Quatd quat_l,quat_r; DecomposeXForm(mtx_l, s_l, h_l, quat_l, t_l); DecomposeXForm(mtx_r, s_r, h_r, quat_r, t_r); Abc::chrono_t amt = (sampleTime-lTime) / (rTime-lTime); if ((quat_l ^ quat_r) < 0) { quat_r = -quat_r; } return RecomposeXForm(lerp(s_l, s_r, amt), lerp(h_l, h_r, amt), Imath::slerp(quat_l, quat_r, amt), lerp(t_l, t_r, amt)); } } //-***************************************************************************** void ConcatenateXformSamples( ProcArgs &args, const MatrixSampleMap & parentSamples, const MatrixSampleMap & localSamples, MatrixSampleMap & outputSamples) { SampleTimeSet unionOfSampleTimes; for (MatrixSampleMap::const_iterator I = parentSamples.begin(); I != parentSamples.end(); ++I) { unionOfSampleTimes.insert((*I).first); } for (MatrixSampleMap::const_iterator I = localSamples.begin(); I != localSamples.end(); ++I) { unionOfSampleTimes.insert((*I).first); } for (SampleTimeSet::iterator I = unionOfSampleTimes.begin(); I != unionOfSampleTimes.end(); ++I) { M44d parentMtx = GetNaturalOrInterpolatedSampleForTime(parentSamples, (*I)); M44d localMtx = GetNaturalOrInterpolatedSampleForTime(localSamples, (*I)); outputSamples[(*I)] = localMtx * parentMtx; } } //-***************************************************************************** Abc::chrono_t GetRelativeSampleTime( ProcArgs &args, Abc::chrono_t sampleTime) { const chrono_t epsilon = 1.0 / 10000.0; chrono_t frameTime = args.frame / args.fps; Abc::chrono_t result = ( sampleTime - frameTime ) * args.fps; if ( fabs( result ) < epsilon ) { result = 0.0; } return result; } alembic-1.8.9/arnold/Procedural/SampleUtil.h000066400000000000000000000055411507001531700207400ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Arnold_SampleUtil_h #define Alembic_Arnold_SampleUtil_h #include #include "ProcArgs.h" #include using namespace Alembic::AbcGeom; typedef std::set SampleTimeSet; typedef std::map MatrixSampleMap; //-***************************************************************************** void GetRelevantSampleTimes( ProcArgs &args, TimeSamplingPtr timeSampling, size_t numSamples, SampleTimeSet &output, MatrixSampleMap * inheritedSamples = 0); //-***************************************************************************** void ConcatenateXformSamples( ProcArgs &args, const MatrixSampleMap & parentSamples, const MatrixSampleMap & localSamples, MatrixSampleMap & outputSamples); //-***************************************************************************** Abc::chrono_t GetRelativeSampleTime( ProcArgs &args, Abc::chrono_t sampleTime); #endif alembic-1.8.9/arnold/Procedural/WriteGeo.cpp000066400000000000000000000436301507001531700207420ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include "WriteGeo.h" #include "ArbGeomParams.h" #include #include //-***************************************************************************** #if AI_VERSION_ARCH_NUM == 3 #if AI_VERSION_MAJOR_NUM < 4 #define AiNodeGetNodeEntry(node) ((node)->base_node) #endif #endif bool nodeHasParameter( struct AtNode * node, const std::string & paramName) { return AiNodeEntryLookUpParameter( AiNodeGetNodeEntry( node ), paramName.c_str() ) != NULL; } //-***************************************************************************** void ApplyTransformation( struct AtNode * node, MatrixSampleMap * xformSamples, ProcArgs &args ) { if ( !node || !xformSamples || xformSamples->empty() ) { return; } // confirm that this node has a parameter if ( !nodeHasParameter( node, "matrix" ) ) { return; } // check to see that we're not a single identity matrix if (xformSamples->size() == 1 && xformSamples->begin()->second == Imath::M44d()) { return; } std::vector sampleTimes; sampleTimes.reserve(xformSamples->size()); std::vector mlist; mlist.reserve( 16* xformSamples->size() ); for ( MatrixSampleMap::iterator I = xformSamples->begin(); I != xformSamples->end(); ++I ) { // build up a vector of relative sample times to feed to // "transform_time_samples" or "time_samples" sampleTimes.push_back( GetRelativeSampleTime(args, (*I).first) ); for (int i = 0; i < 16; i++) { mlist.push_back( (*I).second.getValue()[i] ); } } AiNodeSetArray(node, "matrix", ArrayConvert(1, xformSamples->size(), AI_TYPE_MATRIX, &mlist[0])); if ( sampleTimes.size() > 1 ) { // persp_camera calls it time_samples while the primitives call it // transform_time_samples if ( nodeHasParameter( node, "transform_time_samples" ) ) { AiNodeSetArray(node, "transform_time_samples", ArrayConvert(sampleTimes.size(), 1, AI_TYPE_FLOAT, &sampleTimes[0])); } else if ( nodeHasParameter( node, "time_samples" ) ) { AiNodeSetArray(node, "time_samples", ArrayConvert(sampleTimes.size(), 1, AI_TYPE_FLOAT, &sampleTimes[0])); } else { //TODO, warn if neither is present? Should be there in all //commercial versions of arnold by now. } } } //-***************************************************************************** template void ProcessIndexedBuiltinParam( geomParamT param, const SampleTimeSet & sampleTimes, std::vector & values, std::vector & idxs, size_t elementSize) { if ( !param.valid() ) { return; } bool isFirstSample = true; for ( SampleTimeSet::iterator I = sampleTimes.begin(); I != sampleTimes.end(); ++I, isFirstSample = false) { ISampleSelector sampleSelector( *I ); switch ( param.getScope() ) { case kVaryingScope: case kVertexScope: { // a value per-point, idxs should be the same as vidxs // so we'll leave it empty // we'll get the expanded form here typename geomParamT::Sample sample = param.getExpandedValue( sampleSelector); size_t footprint = sample.getVals()->size() * elementSize; values.reserve( values.size() + footprint ); values.insert( values.end(), (float32_t*) sample.getVals()->get(), ((float32_t*) sample.getVals()->get()) + footprint ); break; } case kFacevaryingScope: { // get the indexed form and feed to nidxs typename geomParamT::Sample sample = param.getIndexedValue( sampleSelector); if ( isFirstSample ) { idxs.reserve( sample.getIndices()->size() ); idxs.insert( idxs.end(), sample.getIndices()->get(), sample.getIndices()->get() + sample.getIndices()->size() ); } size_t footprint = sample.getVals()->size() * elementSize; values.reserve( values.size() + footprint ); values.insert( values.end(), (const float32_t*) sample.getVals()->get(), ((const float32_t*) sample.getVals()->get()) + footprint ); break; } default: break; } } } //-***************************************************************************** namespace { // Arnold scene build is single-threaded so we don't have to lock around // access to this for now. typedef std::map NodeCache; NodeCache g_meshCache; } //-************************************************************************* // This is templated to handle shared behavior of IPolyMesh and ISubD // We send in our empty sampleTimes and vidxs because polymesh needs those // for processing animated normal. // The return value is the polymesh node. If instanced, it will be returned // for the first created instance only. template AtNode * ProcessPolyMeshBase( primT & prim, ProcArgs & args, SampleTimeSet & sampleTimes, std::vector & vidxs, int subdiv_iterations, MatrixSampleMap * xformSamples, const std::string & facesetName = "" ) { if ( !prim.valid() ) { return NULL; } typename primT::schema_type &ps = prim.getSchema(); TimeSamplingPtr ts = ps.getTimeSampling(); if ( ps.getTopologyVariance() != kHeterogenousTopology ) { GetRelevantSampleTimes( args, ts, ps.getNumSamples(), sampleTimes ); } else { sampleTimes.insert( args.frame / args.fps ); } std::string name = args.nameprefix + prim.getFullName(); AtNode * instanceNode = NULL; std::string cacheId; if ( args.makeInstance ) { std::ostringstream buffer; AbcA::ArraySampleKey sampleKey; for ( SampleTimeSet::iterator I = sampleTimes.begin(); I != sampleTimes.end(); ++I ) { ISampleSelector sampleSelector( *I ); ps.getPositionsProperty().getKey(sampleKey, sampleSelector); buffer << GetRelativeSampleTime( args, (*I) ) << ":"; sampleKey.digest.print(buffer); buffer << ":"; } buffer << "@" << subdiv_iterations; buffer << "@" << facesetName; cacheId = buffer.str(); instanceNode = AiNode( "ginstance" ); AiNodeSetStr( instanceNode, "name", name.c_str() ); args.createdNodes.push_back(instanceNode); if ( args.proceduralNode ) { AiNodeSetInt( instanceNode, "visibility", AiNodeGetInt( args.proceduralNode, "visibility" ) ); } else { AiNodeSetInt( instanceNode, "visibility", AI_RAY_ALL ); } ApplyTransformation( instanceNode, xformSamples, args ); NodeCache::iterator I = g_meshCache.find(cacheId); if ( I != g_meshCache.end() ) { AiNodeSetPtr(instanceNode, "node", (*I).second ); return NULL; } } SampleTimeSet singleSampleTimes; singleSampleTimes.insert( args.frame / args.fps ); std::vector nsides; std::vector vlist; std::vector uvlist; std::vector uvidxs; // POTENTIAL OPTIMIZATIONS LEFT TO THE READER // 1) vlist needn't be copied if it's a single sample bool isFirstSample = true; for ( SampleTimeSet::iterator I = sampleTimes.begin(); I != sampleTimes.end(); ++I, isFirstSample = false) { ISampleSelector sampleSelector( *I ); typename primT::schema_type::Sample sample = ps.getValue( sampleSelector ); if ( isFirstSample ) { size_t numPolys = sample.getFaceCounts()->size(); nsides.reserve( sample.getFaceCounts()->size() ); for ( size_t i = 0; i < numPolys; ++i ) { int32_t n = sample.getFaceCounts()->get()[i]; if ( n > 255 ) { // TODO, warning about unsupported face return NULL; } nsides.push_back( (AtByte) n ); } size_t vidxSize = sample.getFaceIndices()->size(); vidxs.reserve( vidxSize ); vidxs.insert( vidxs.end(), sample.getFaceIndices()->get(), sample.getFaceIndices()->get() + vidxSize ); } vlist.reserve( vlist.size() + sample.getPositions()->size() * 3); vlist.insert( vlist.end(), (const float32_t*) sample.getPositions()->get(), ((const float32_t*) sample.getPositions()->get()) + sample.getPositions()->size() * 3 ); } ProcessIndexedBuiltinParam( ps.getUVsParam(), singleSampleTimes, uvlist, uvidxs, 2); AtNode* meshNode = AiNode( "polymesh" ); if (!meshNode) { AiMsgError("Failed to make polymesh node for %s", prim.getFullName().c_str()); return NULL; } args.createdNodes.push_back(meshNode); if ( instanceNode != NULL) { AiNodeSetStr( meshNode, "name", (name + ":src").c_str() ); } else { AiNodeSetStr( meshNode, "name", name.c_str() ); } AiNodeSetArray(meshNode, "vidxs", ArrayConvert(vidxs.size(), 1, AI_TYPE_UINT, (void*)&vidxs[0])); AiNodeSetArray(meshNode, "nsides", ArrayConvert(nsides.size(), 1, AI_TYPE_BYTE, &(nsides[0]))); AiNodeSetArray(meshNode, "vlist", ArrayConvert( vlist.size() / sampleTimes.size(), sampleTimes.size(), AI_TYPE_FLOAT, (void*)(&(vlist[0])))); if ( !uvlist.empty() ) { //TODO, option to disable v flipping for (size_t i = 1, e = uvlist.size(); i < e; i += 2) { uvlist[i] = 1.0 - uvlist[i]; } AiNodeSetArray(meshNode, "uvlist", ArrayConvert( uvlist.size(), 1, AI_TYPE_FLOAT, (void*)(&(uvlist[0])))); if ( !uvidxs.empty() ) { AiNodeSetArray(meshNode, "uvidxs", ArrayConvert(uvidxs.size(), 1, AI_TYPE_UINT, &(uvidxs[0]))); } else { AiNodeSetArray(meshNode, "uvidxs", ArrayConvert(vidxs.size(), 1, AI_TYPE_UINT, &(vidxs[0]))); } } if ( sampleTimes.size() > 1 ) { std::vector relativeSampleTimes; relativeSampleTimes.reserve( sampleTimes.size() ); for (SampleTimeSet::const_iterator I = sampleTimes.begin(); I != sampleTimes.end(); ++I ) { relativeSampleTimes.push_back( GetRelativeSampleTime( args, (*I) ) ); } AiNodeSetArray( meshNode, "deform_time_samples", ArrayConvert(relativeSampleTimes.size(), 1, AI_TYPE_FLOAT, &relativeSampleTimes[0])); } // faceset visibility array if ( !facesetName.empty() ) { if ( ps.hasFaceSet( facesetName ) ) { ISampleSelector frameSelector( *singleSampleTimes.begin() ); IFaceSet faceSet = ps.getFaceSet( facesetName ); IFaceSetSchema::Sample faceSetSample = faceSet.getSchema().getValue( frameSelector ); std::set facesToKeep; facesToKeep.insert( faceSetSample.getFaces()->get(), faceSetSample.getFaces()->get() + faceSetSample.getFaces()->size() ); bool *faceVisArray = new bool(nsides.size()); for ( int i = 0; i < (int) nsides.size(); ++i ) { faceVisArray[i] = facesToKeep.find( i ) != facesToKeep.end(); } if ( AiNodeDeclare( meshNode, "face_visibility", "uniform BOOL" ) ) { AiNodeSetArray( meshNode, "face_visibility", ArrayConvert( nsides.size(), 1, AI_TYPE_BOOLEAN, faceVisArray ) ); } delete[] faceVisArray; } } { ICompoundProperty arbGeomParams = ps.getArbGeomParams(); ISampleSelector frameSelector( *singleSampleTimes.begin() ); AddArbitraryGeomParams( arbGeomParams, frameSelector, meshNode ); } if ( instanceNode == NULL ) { if ( xformSamples ) { ApplyTransformation( meshNode, xformSamples, args ); } return meshNode; } else { AiNodeSetInt( meshNode, "visibility", 0 ); AiNodeSetPtr(instanceNode, "node", meshNode ); g_meshCache[cacheId] = meshNode; return meshNode; } } //-************************************************************************* void ProcessPolyMesh( IPolyMesh &polymesh, ProcArgs &args, MatrixSampleMap * xformSamples, const std::string & facesetName ) { SampleTimeSet sampleTimes; std::vector vidxs; AtNode * meshNode = ProcessPolyMeshBase( polymesh, args, sampleTimes, vidxs, 0, xformSamples, facesetName ); // This is a valid condition for the second instance onward and just // means that we don't need to do anything further. if ( !meshNode ) { return; } IPolyMeshSchema &ps = polymesh.getSchema(); std::vector nlist; std::vector nidxs; ProcessIndexedBuiltinParam( ps.getNormalsParam(), sampleTimes, nlist, nidxs, 3); if ( !nlist.empty() ) { AiNodeSetArray(meshNode, "nlist", ArrayConvert( nlist.size() / sampleTimes.size(), sampleTimes.size(), AI_TYPE_FLOAT, (void*)(&(nlist[0])))); if ( !nidxs.empty() ) { AiNodeSetArray(meshNode, "nidxs", ArrayConvert(nidxs.size(), 1, AI_TYPE_UINT, &(nidxs[0]))); } else { AiNodeSetArray(meshNode, "nidxs", ArrayConvert(vidxs.size(), 1, AI_TYPE_UINT, &(vidxs[0]))); } } } //-************************************************************************* void ProcessSubD( ISubD &subd, ProcArgs &args, MatrixSampleMap * xformSamples, const std::string & facesetName ) { SampleTimeSet sampleTimes; std::vector vidxs; AtNode * meshNode = ProcessPolyMeshBase( subd, args, sampleTimes, vidxs, args.subdIterations, xformSamples, facesetName ); // This is a valid condition for the second instance onward and just // means that we don't need to do anything further. if ( !meshNode ) { return; } AiNodeSetStr( meshNode, "subdiv_type", "catclark" ); } alembic-1.8.9/arnold/Procedural/WriteGeo.h000066400000000000000000000050731507001531700204060ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Arnold_WriteGeo_h #define Alembic_Arnold_WriteGeo_h #include #include "ProcArgs.h" #include "SampleUtil.h" using namespace Alembic::AbcGeom; //-***************************************************************************** void ProcessPolyMesh( IPolyMesh &polymesh, ProcArgs &args, MatrixSampleMap * xformSamples, const std::string & facesetName = ""); void ProcessSubD( ISubD &subd, ProcArgs &args, MatrixSampleMap * xformSamples, const std::string & facesetName = ""); // void ProcessNuPatch( INuPatch &patch, ProcArgs &args ); // // void ProcessPoints( IPoints &patch, ProcArgs &args ); // // void ProcessCurves( ICurves &curves, ProcArgs &args ); #endif alembic-1.8.9/arnold/Tests/000077500000000000000000000000001507001531700155055ustar00rootroot00000000000000alembic-1.8.9/arnold/Tests/CMakeLists.txt000066400000000000000000000041241507001531700202460ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2011, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Sony Pictures Imageworks, nor ## Industrial Light & Magic, nor the names of their contributors may be used ## to endorse or promote products derived from this software without specific ## prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** INCLUDE_DIRECTORIES( ${ALEMBIC_ARNOLD_INCLUDE_PATH} ) SET( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ) ADD_EXECUTABLE( arnold_procedural_testbed testbed.cpp ) TARGET_LINK_LIBRARIES( arnold_procedural_testbed ${ALEMBIC_ARNOLD_LIBARNOLD} dl ) alembic-1.8.9/arnold/Tests/testbed.cpp000066400000000000000000000054261507001531700176520ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2015, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include void usage() { std::cerr << "runs an arnold procedural and spits out ass" << std::endl; std::cerr << "usage:" << std::endl; std::cerr << "testbed pathto.so [args...]" << std::endl; } int main(int argc, char **argv) { if (argc < 2) { usage(); return 1; } std::ostringstream buffer; if (argc > 2) { for (int i = 2; i < argc; ++i) { buffer << argv[i] << " "; } } AiBegin(); AiMsgSetConsoleFlags(AI_LOG_WARNINGS );//| AI_LOG_BACKTRACE); AtNode* procedural = AiNode("procedural"); AiNodeSetStr(procedural, "name", "testbed"); AiNodeSetStr(procedural, "dso", argv[1]); AiNodeSetStr(procedural, "data", buffer.str().c_str()); AiNodeSetInt(procedural, "visibility", AI_RAY_CAMERA); AiASSWrite("/dev/stdout", AI_NODE_ALL, true); AiEnd(); } alembic-1.8.9/bin/000077500000000000000000000000001507001531700136745ustar00rootroot00000000000000alembic-1.8.9/bin/AbcConvert/000077500000000000000000000000001507001531700157225ustar00rootroot00000000000000alembic-1.8.9/bin/AbcConvert/AbcConvert.cpp000066400000000000000000000300031507001531700204500ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include typedef Alembic::AbcCoreFactory::IFactory IFactoryNS; enum ArgMode { kOptions, kInFiles, kOutFile, }; class ConversionOptions { public: ConversionOptions() { toType = IFactoryNS::kUnknown; force = false; } std::vector inFiles; std::string outFile; IFactoryNS::CoreType toType; bool force; }; void copyProps(Alembic::Abc::ICompoundProperty & iRead, Alembic::Abc::OCompoundProperty & iWrite) { std::size_t numChildren = iRead.getNumProperties(); for (std::size_t i = 0; i < numChildren; ++i) { Alembic::AbcCoreAbstract::PropertyHeader header = iRead.getPropertyHeader(i); if (header.isArray()) { Alembic::Abc::IArrayProperty inProp(iRead, header.getName()); Alembic::Abc::OArrayProperty outProp(iWrite, header.getName(), header.getDataType(), header.getMetaData(), header.getTimeSampling()); std::size_t numSamples = inProp.getNumSamples(); for (std::size_t j = 0; j < numSamples; ++j) { Alembic::AbcCoreAbstract::ArraySamplePtr samp; Alembic::Abc::ISampleSelector sel( (Alembic::Abc::index_t) j); inProp.get(samp, sel); outProp.set(*samp); } } else if (header.isScalar()) { Alembic::Abc::IScalarProperty inProp(iRead, header.getName()); Alembic::Abc::OScalarProperty outProp(iWrite, header.getName(), header.getDataType(), header.getMetaData(), header.getTimeSampling()); std::size_t numSamples = inProp.getNumSamples(); std::vector sampStrVec; std::vector sampWStrVec; if (header.getDataType().getPod() == Alembic::AbcCoreAbstract::kStringPOD) { sampStrVec.resize(header.getDataType().getExtent()); } else if (header.getDataType().getPod() == Alembic::AbcCoreAbstract::kWstringPOD) { sampWStrVec.resize(header.getDataType().getExtent()); } char samp[4096]; for (std::size_t j = 0; j < numSamples; ++j) { Alembic::Abc::ISampleSelector sel( (Alembic::Abc::index_t) j); if (header.getDataType().getPod() == Alembic::AbcCoreAbstract::kStringPOD) { inProp.get(&sampStrVec.front(), sel); outProp.set(&sampStrVec.front()); } else if (header.getDataType().getPod() == Alembic::AbcCoreAbstract::kWstringPOD) { inProp.get(&sampWStrVec.front(), sel); outProp.set(&sampWStrVec.front()); } else { inProp.get(samp, sel); outProp.set(samp); } } } else if (header.isCompound()) { Alembic::Abc::OCompoundProperty outProp(iWrite, header.getName(), header.getMetaData()); Alembic::Abc::ICompoundProperty inProp(iRead, header.getName()); copyProps(inProp, outProp); } } } void copyObject(Alembic::Abc::IObject & iIn, Alembic::Abc::OObject & iOut) { std::size_t numChildren = iIn.getNumChildren(); Alembic::Abc::ICompoundProperty inProps = iIn.getProperties(); Alembic::Abc::OCompoundProperty outProps = iOut.getProperties(); copyProps(inProps, outProps); for (std::size_t i = 0; i < numChildren; ++i) { Alembic::Abc::IObject childIn(iIn.getChild(i)); Alembic::Abc::OObject childOut(iOut, childIn.getName(), childIn.getMetaData()); copyObject(childIn, childOut); } } void displayHelp() { printf ("Usage (single file conversion):\n"); printf ("abcconvert [-force] OPTION inFile outFile\n"); printf ("Usage (convert multiple, layered files to single file):\n"); printf ("abcconvert OPTION -in inFile1 inFile2 ... -out outFile\n"); printf ("Used to convert an Alembic file from one type to another.\n\n"); printf ("If -force is not provided and inFile happens to be the same\n"); printf ("type as OPTION no conversion will be done and a message will\n"); printf ("be printed out.\n"); printf ("OPTION has to be one of these:\n\n"); printf (" -toHDF Convert to HDF.\n"); printf (" -toOgawa Convert to Ogawa.\n"); } bool parseArgs( int iArgc, char *iArgv[], ConversionOptions &oOptions, bool &oDoConversion ) { oDoConversion = true; ArgMode argMode = kOptions; for( int i = 1; i < iArgc; i++ ) { bool argHandled = true; std::string arg = iArgv[i]; switch( argMode ) { case kOptions: { if(arg == "-toHDF") { oOptions.toType = IFactoryNS::kHDF5; } else if(arg == "-toOgawa") { oOptions.toType = IFactoryNS::kOgawa; } else if(arg == "-force") { oOptions.force = true; } else if(arg == "-in" ) { argMode = kInFiles; } else if( (arg == "-help") || (arg == "--help") ) { displayHelp(); oDoConversion = false; return true; } else if(arg.c_str()[0] == '-') { argHandled = false; } else { argMode = kInFiles; i--; } } break; case kInFiles: { if(arg == "-out") { argMode = kOutFile; } else if( i == (iArgc - 1) ) { argMode = kOutFile; i--; } else { oOptions.inFiles.push_back( arg ); } } break; case kOutFile: { if(oOptions.outFile == "") { oOptions.outFile = arg; } else { argHandled = false; } } break; } if( !argHandled ) { displayHelp(); oDoConversion = false; return false; } } if( (oOptions.inFiles.size() == 0) || (oOptions.outFile.length() == 0) || (oOptions.toType == IFactoryNS::kUnknown) ) { printf( "Bad syntax!\n\n"); displayHelp(); oDoConversion = false; return false; } return true; } int main(int argc, char *argv[]) { ConversionOptions options; bool doConversion = false; if (parseArgs( argc, argv, options, doConversion ) == false) return 1; if (doConversion) { for( std::vector::const_iterator inFile = options.inFiles.begin(); inFile != options.inFiles.end(); inFile++ ) { if (*inFile == options.outFile) { printf("Error: inFile and outFile must not be the same!\n"); return 1; } } if (options.toType != IFactoryNS::kHDF5 && options.toType != IFactoryNS::kOgawa) { printf("Currently only -toHDF and -toOgawa are supported.\n"); return 1; } Alembic::AbcCoreFactory::IFactory factory; Alembic::AbcCoreFactory::IFactory::CoreType coreType; Alembic::Abc::IArchive archive; if(options.inFiles.size() == 1) { archive = factory.getArchive(*options.inFiles.begin(), coreType); if (!archive.valid()) { printf("Error: Invalid Alembic file specified: %s\n", options.inFiles.begin()->c_str()); return 1; } else if ( !options.force && ( (coreType == IFactoryNS::kHDF5 && options.toType == IFactoryNS::kHDF5) || (coreType == IFactoryNS::kOgawa && options.toType == IFactoryNS::kOgawa)) ) { printf("Warning: Alembic file specified: %s\n", options.inFiles.begin()->c_str()); printf("is already of the type you want to convert to.\n"); printf("Please specify -force if you want to do this anyway.\n"); return 1; } } else { archive = factory.getArchive(options.inFiles, coreType); } Alembic::Abc::IObject inTop = archive.getTop(); Alembic::Abc::OArchive outArchive; if (options.toType == IFactoryNS::kHDF5) { outArchive = Alembic::Abc::OArchive( Alembic::AbcCoreHDF5::WriteArchive(), options.outFile, inTop.getMetaData(), Alembic::Abc::ErrorHandler::kThrowPolicy); } else if (options.toType == IFactoryNS::kOgawa) { outArchive = Alembic::Abc::OArchive( Alembic::AbcCoreOgawa::WriteArchive(), options.outFile, inTop.getMetaData(), Alembic::Abc::ErrorHandler::kThrowPolicy); } // start at 1, we don't need to worry about intrinsic default case for (Alembic::Util::uint32_t i = 1; i < archive.getNumTimeSamplings(); ++i) { outArchive.addTimeSampling(*archive.getTimeSampling(i)); } Alembic::Abc::OObject outTop = outArchive.getTop(); copyObject(inTop, outTop); } return 0; } alembic-1.8.9/bin/AbcConvert/CMakeLists.txt000066400000000000000000000041171507001531700204650ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2013-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** ADD_EXECUTABLE(abcconvert AbcConvert.cpp) TARGET_LINK_LIBRARIES(abcconvert Alembic::Alembic) set_target_properties(abcconvert PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) INSTALL(TARGETS abcconvert DESTINATION bin) alembic-1.8.9/bin/AbcDiff/000077500000000000000000000000001507001531700151525ustar00rootroot00000000000000alembic-1.8.9/bin/AbcDiff/AbcDiff.cpp000066400000000000000000000553711507001531700171470ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2016, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #include // util which compares the property headers and returns if they are the same bool headerCmp(const Alembic::Abc::PropertyHeader * iHeaderA, const Alembic::Abc::PropertyHeader * iHeaderB) { // we've already done the name check if (iHeaderA->getPropertyType() != iHeaderB->getPropertyType() && iHeaderA->getMetaData().serialize() != iHeaderB->getMetaData().serialize()) { return false; } // nothing more to check for compounds if (iHeaderA->isCompound()) { return true; } return (iHeaderA->getDataType() == iHeaderB->getDataType()) && (*(iHeaderA->getTimeSampling()) == *(iHeaderB->getTimeSampling())); } // util used in verbose mode to get the full property name void fillFullPropName(Alembic::Abc::ICompoundProperty iProp, std::string & ioName) { while(iProp.getParent().valid()) { if (ioName.empty()) { ioName = iProp.getName(); } else { ioName = iProp.getName() + "/" + ioName; } iProp = iProp.getParent(); } } // copies the entire array property to iParent void copyArrayProp(Alembic::Abc::IArrayProperty & iProp, Alembic::Abc::OCompoundProperty & iParent, bool iVerbose) { if (iVerbose) { std::string propName = iProp.getName(); fillFullPropName(iProp.getParent(), propName); printf ("%s array prop diff on %s\n", iProp.getObject().getFullName().c_str(), propName.c_str()); } Alembic::Abc::OArrayProperty outProp(iParent, iProp.getName(), iProp.getDataType(), iProp.getMetaData(), iProp.getTimeSampling()); std::size_t numSamples = iProp.getNumSamples(); for (std::size_t i = 0; i < numSamples; ++i) { Alembic::Abc::ArraySamplePtr samp; Alembic::Abc::ISampleSelector sel((Alembic::Abc::index_t) i); iProp.get(samp, sel); outProp.set(*samp); } } // copies the entire static array property to iParent void copyStaticProp(Alembic::Abc::IScalarProperty & iProp, Alembic::Abc::OCompoundProperty & iParent, bool iVerbose) { if (iVerbose) { std::string propName = iProp.getName(); fillFullPropName(iProp.getParent(), propName); printf ("%s scalar prop diff on %s\n", iProp.getObject().getFullName().c_str(), propName.c_str()); } Alembic::Abc::OScalarProperty outProp(iParent, iProp.getName(), iProp.getDataType(), iProp.getMetaData(), iProp.getTimeSampling()); std::size_t numSamples = iProp.getNumSamples(); std::vector sampStrVec; std::vector sampWStrVec; Alembic::Util::PlainOldDataType ptype = iProp.getDataType().getPod(); if (ptype == Alembic::Util::kStringPOD) { sampStrVec.resize(iProp.getDataType().getExtent()); } else if (ptype == Alembic::Util::kWstringPOD) { sampWStrVec.resize(iProp.getDataType().getExtent()); } char samp[4096]; for (std::size_t i = 0; i < numSamples; ++i) { Alembic::Abc::ISampleSelector sel((Alembic::Abc::index_t) i); if (ptype == Alembic::Util::kStringPOD) { iProp.get(&sampStrVec.front(), sel); outProp.set(&sampStrVec.front()); } else if (ptype == Alembic::Abc::kWstringPOD) { iProp.get(&sampWStrVec.front(), sel); outProp.set(&sampWStrVec.front()); } else { iProp.get(samp, sel); outProp.set(samp); } } } // copies all of the compound hierachy to iWrite void copyProps(Alembic::Abc::ICompoundProperty & iRead, Alembic::Abc::OCompoundProperty & iWrite, bool iVerbose) { if (iVerbose) { std::string propName; fillFullPropName(iRead, propName); printf ("%s compound prop diff on %s\n", iRead.getObject().getFullName().c_str(), propName.c_str()); } std::size_t numChildren = iRead.getNumProperties(); for (std::size_t i = 0; i < numChildren; ++i) { Alembic::Abc::PropertyHeader header = iRead.getPropertyHeader(i); if (header.isArray()) { Alembic::Abc::IArrayProperty inProp(iRead, header.getName()); copyArrayProp(inProp, iWrite, false); } else if (header.isScalar()) { Alembic::Abc::IScalarProperty inProp(iRead, header.getName()); copyStaticProp(inProp, iWrite, false); } else if (header.isCompound()) { Alembic::Abc::OCompoundProperty outProp(iWrite, header.getName(), header.getMetaData()); Alembic::Abc::ICompoundProperty inProp(iRead, header.getName()); copyProps(inProp, outProp, false); } } } // copies object hierarchy and its property void copyObject(Alembic::Abc::IObject & iIn, Alembic::Abc::OObject & iOut) { std::size_t numChildren = iIn.getNumChildren(); Alembic::Abc::ICompoundProperty inProps = iIn.getProperties(); Alembic::Abc::OCompoundProperty outProps = iOut.getProperties(); copyProps(inProps, outProps, false); for (std::size_t i = 0; i < numChildren; ++i) { Alembic::Abc::IObject childIn(iIn.getChild(i)); Alembic::Abc::OObject childOut(iOut, childIn.getName(), childIn.getMetaData()); copyObject(childIn, childOut); } } // class which walks the hierarchy, writes out hiearchy and properties // that are different in iInFileB from iInFileA, and prunes hierarchy and // properties which are in iInFileA but not iInFileB. class DiffWalker { public: DiffWalker(const char * iInFileA, const char * iInFileB, const char * iOutFile, bool iVerbose) { m_verbose = iVerbose; m_inFileA = iInFileA; m_inFileB = iInFileB; m_outFile = iOutFile; } int walk() { Alembic::AbcCoreFactory::IFactory factory; Alembic::AbcCoreFactory::IFactory::CoreType coreType; Alembic::Abc::IArchive arc1 = factory.getArchive(m_inFileA, coreType); if (coreType != Alembic::AbcCoreFactory::IFactory::kOgawa) { printf("Error: %s is not a valid Alembic Ogawa file.\n", m_inFileA.c_str()); return 1; } Alembic::Abc::IArchive arc2 = factory.getArchive(m_inFileB, coreType); if (coreType != Alembic::AbcCoreFactory::IFactory::kOgawa) { printf("Error: %s is not a valid Alembic Ogawa file.\n", m_inFileB.c_str()); return 1; } Alembic::Abc::IObject topA = arc1.getTop(); Alembic::Abc::IObject topB = arc2.getTop(); walk(topA, topB); if (m_outStack.empty()) { printf("No differences detected, %s was not written.\n", m_outFile.c_str()); } return 0; } private: void walkProps(Alembic::Abc::ICompoundProperty & iPropA, Alembic::Abc::ICompoundProperty & iPropB, Alembic::Abc::OCompoundProperty & oProp) { for (size_t i = 0; i < iPropA.getNumProperties(); ++i) { Alembic::Abc::PropertyHeader childAHeader = iPropA.getPropertyHeader(i); const Alembic::Abc::PropertyHeader * childBHeader = iPropB.getPropertyHeader(childAHeader.getName()); // prune this property if (!childBHeader) { if (m_verbose) { std::string propName = childAHeader.getName(); fillFullPropName(iPropA, propName); printf("%s pruning prop: %s.\n", iPropA.getObject().getFullName().c_str(), propName.c_str()); } Alembic::Abc::MetaData md; Alembic::AbcCoreLayer::SetPrune(md, true); Alembic::Abc::OCompoundProperty pruneProp(oProp, childAHeader.getName(), md); continue; } if (!headerCmp(&childAHeader, childBHeader)) { if (childBHeader->isArray()) { Alembic::Abc::IArrayProperty inProp(iPropB, childBHeader->getName()); copyArrayProp(inProp, oProp, m_verbose); } else if (childBHeader->isScalar()) { Alembic::Abc::IScalarProperty inProp(iPropB, childBHeader->getName()); copyStaticProp(inProp, oProp, m_verbose); } else if (childBHeader->isCompound()) { Alembic::Abc::OCompoundProperty outProp(oProp, childBHeader->getName(), childBHeader->getMetaData()); Alembic::Abc::ICompoundProperty inProp(iPropB, childBHeader->getName()); copyProps(inProp, outProp, m_verbose); } continue; } // if childAHeader != *childBHeader // headers are equal do more checks if (childAHeader.isCompound()) { Alembic::Abc::ICompoundProperty childA(iPropA, childAHeader.getName()); Alembic::Abc::ICompoundProperty childB(iPropB, childAHeader.getName()); // dont copy metadata here, since it was the same Alembic::Abc::OCompoundProperty outProp(oProp, childAHeader.getName()); walkProps(childA, childB, outProp); } else if (childAHeader.isScalar()) { Alembic::Abc::IScalarProperty childA(iPropA, childAHeader.getName()); Alembic::Abc::IScalarProperty childB(iPropB, childAHeader.getName()); if (childA.getNumSamples() != childB.getNumSamples()) { copyStaticProp(childB, oProp, m_verbose); continue; } std::vector sampStrVecA, sampStrVecB; std::vector sampWStrVecA, sampWStrVecB; char sampA[4096]; char sampB[4096]; std::size_t numBytes = 0; Alembic::Util::PlainOldDataType ptype = childB.getDataType().getPod(); if (ptype == Alembic::Util::kStringPOD) { sampStrVecA.resize(childB.getDataType().getExtent()); sampStrVecB.resize(childB.getDataType().getExtent()); } else if (ptype == Alembic::Util::kWstringPOD) { sampWStrVecA.resize(childB.getDataType().getExtent()); sampWStrVecB.resize(childB.getDataType().getExtent()); } else { memset(sampA, 0, 4096); memset(sampB, 0, 4096); numBytes = childB.getDataType().getNumBytes(); } Alembic::Abc::index_t j; Alembic::Abc::index_t numSamples = childB.getNumSamples(); for (j = 0; j < numSamples; ++j) { if (ptype == Alembic::Util::kStringPOD) { childA.get(&sampStrVecA.front(), j); childB.get(&sampStrVecB.front(), j); if (sampStrVecA != sampStrVecB) { copyStaticProp(childB, oProp, m_verbose); break; } } else if (ptype == Alembic::Util::kWstringPOD) { childA.get(&sampWStrVecA.front(), j); childB.get(&sampWStrVecB.front(), j); if (sampWStrVecA != sampWStrVecB) { copyStaticProp(childB, oProp, m_verbose); break; } } else { childA.get(sampA, j); childB.get(sampB, j); if (memcmp(sampA, sampB, numBytes) != 0) { copyStaticProp(childB, oProp, m_verbose); break; } } } } else if (childAHeader.isArray()) { Alembic::Abc::IArrayProperty childA(iPropA, childAHeader.getName()); Alembic::Abc::IArrayProperty childB(iPropB, childAHeader.getName()); if (childA.getNumSamples() != childB.getNumSamples()) { copyArrayProp(childB, oProp, m_verbose); continue; } Alembic::Abc::index_t j; Alembic::Abc::index_t numSamples = childB.getNumSamples(); for (j = 0; j < numSamples; ++j) { Alembic::Abc::ArraySampleKey keyA, keyB; childA.getKey(keyA, j); childB.getKey(keyB, j); if (keyA != keyB) { copyArrayProp(childB, oProp, m_verbose); break; } } } } } void walkProps(Alembic::Abc::ICompoundProperty & iPropA, Alembic::Abc::ICompoundProperty & iPropB) { if (Alembic::AbcGeom::IXform::matches(iPropB.getMetaData())) { fillStack(iPropB.getObject().getParent().getFullName()); Alembic::Abc::MetaData md = iPropB.getMetaData(); Alembic::AbcCoreLayer::SetReplace(md, true); m_outStack.push_back(Alembic::Abc::OObject(m_outStack.back(), iPropB.getObject().getName(), md)); Alembic::Abc::OCompoundProperty oprop = m_outStack.back().getProperties(); copyProps(iPropB, oprop, m_verbose); // This does not handle arbGeomParam and user props that are in // iPropA but not iPropB (normally would prune) return; } else if (iPropA.getMetaData().serialize() != iPropB.getMetaData().serialize() && iPropB.getObject().getParent().valid()) { fillStack(iPropB.getObject().getParent().getFullName()); m_outStack.push_back(Alembic::Abc::OObject(m_outStack.back(), iPropB.getObject().getName(), iPropB.getMetaData())); } else { fillStack(iPropB.getObject().getFullName()); } Alembic::Abc::OCompoundProperty prop = m_outStack.back().getProperties(); walkProps(iPropA, iPropB, prop); } void walk(Alembic::Abc::IObject & iObjA, Alembic::Abc::IObject & iObjB) { Alembic::Util::Digest hashPropA, hashPropB; iObjA.getPropertiesHash(hashPropA); iObjB.getPropertiesHash(hashPropB); // lets check our properties if (hashPropA != hashPropB) { Alembic::Abc::ICompoundProperty propA = iObjA.getProperties(); Alembic::Abc::ICompoundProperty propB = iObjB.getProperties(); walkProps(propA, propB); } Alembic::Util::Digest hashChildrenA, hashChildrenB; iObjA.getChildrenHash(hashChildrenA); iObjB.getChildrenHash(hashChildrenB); if (hashChildrenA == hashChildrenB) { if (m_outStack.size() > 1 && m_outStack.back().getFullName() == iObjA.getFullName()) { m_outStack.pop_back(); } return; } for (size_t i = 0; i < iObjA.getNumChildren(); ++i) { Alembic::Abc::ObjectHeader headerA = iObjA.getChildHeader(i); const Alembic::Abc::ObjectHeader * headerB = iObjB.getChildHeader(headerA.getName()); // prune if (!headerB) { fillStack(iObjA.getParent().getFullName()); Alembic::Abc::MetaData md; Alembic::AbcCoreLayer::SetPrune(md, true); Alembic::Abc::OObject pruneObj(m_outStack.back(), headerA.getName(), md); if (m_verbose) { printf("%s pruned.\n", headerA.getFullName().c_str()); } } else { Alembic::Abc::IObject childA(iObjA, headerA.getName()); Alembic::Abc::IObject childB(iObjB, headerA.getName()); walk(childA, childB); } } // check to see if B introduced any new children for (size_t i = 0; i < iObjB.getNumChildren(); ++i) { Alembic::Abc::ObjectHeader headerB = iObjB.getChildHeader(i); const Alembic::Abc::ObjectHeader * headerA = iObjA.getChildHeader(headerB.getName()); if (headerA == NULL) { Alembic::Abc::IObject childB(iObjB, headerB.getName()); fillStack(iObjB.getParent().getFullName()); Alembic::Abc::OObject out(m_outStack.back(), childB.getName(), childB.getMetaData()); if (m_verbose) { printf("%s copying hierarchy.\n", childB.getFullName().c_str()); } copyObject(childB, out); } } if (m_outStack.size() > 1 && m_outStack.back().getFullName() == iObjA.getFullName()) { m_outStack.pop_back(); } } // fills in m_outStack with empty OObjects based on where we are in the // hierarchy void fillStack(const std::string & iFullName) { if (m_outStack.empty()) { std::string appStr = "AbcDiff"; std::string userDesc = m_inFileA + " " + m_inFileB; Alembic::Abc::OArchive arc = Alembic::Abc::CreateArchiveWithInfo( Alembic::AbcCoreOgawa::WriteArchive(), m_outFile, appStr, userDesc); m_outStack.push_back(arc.getTop()); } // and we are done if (iFullName.empty() || iFullName == m_outStack.back().getFullName()) { return; } // only create what we need in the stack size_t lastIdx = m_outStack.back().getFullName().size(); if (lastIdx > 1) { lastIdx ++; } size_t curIdx = std::string::npos; do { curIdx = iFullName.find('/', lastIdx); m_outStack.push_back(Alembic::Abc::OObject(m_outStack.back(), iFullName.substr(lastIdx, curIdx - lastIdx))); if (curIdx != std::string::npos) { lastIdx = curIdx + 1; } } while (curIdx != std::string::npos); } bool m_verbose; std::string m_inFileA; std::string m_inFileB; std::string m_outFile; std::vector m_outStack; }; void displayHelp() { printf("Usage:\n"); printf("abcdiff [-v] inputFilename1 inputFilename2 outputFilename\n\n"); printf("Used to compare two Alembic files and write an Alembic file that contains the differences.\n\n"); printf("inputFilename1 is the \"base\" file. If there a difference in the object hierarchy of inputFilename2, " "that different object will be added to the diff, along with a skeleton of its parent hierarchy. If an " "object exists in both inputFilename1 and inputFilename2 but the properties are different, an object will " "be added to the diff that contains only the differing properties.\n\n"); printf("Parameters:\n"); printf("-v\t\tOPTIONAL\tVerbose mode prints more detailed information about the diff process\n"); printf("inputFilename1\tREQUIRED\tThe first Alembic file to compare\n"); printf("inputFilename2\tREQUIRED\tThe second Alembic file to compare\n"); printf("outputFilename\tREQUIRED\tThe filename to write out the Alembic diff file\n"); } int main(int argc, char *argv[]) { if ((argc != 4 && argc != 5)|| (argc == 5 && std::string("-v") != argv[1])) { displayHelp(); return 1; } bool verbose = false; // we've already checked for -v above if (argc == 5) { verbose = true; } DiffWalker dw(argv[argc-3], argv[argc-2], argv[argc-1], verbose); dw.walk(); } alembic-1.8.9/bin/AbcDiff/CMakeLists.txt000066400000000000000000000040731507001531700177160ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2016, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** ADD_EXECUTABLE(abcdiff AbcDiff.cpp) TARGET_LINK_LIBRARIES(abcdiff Alembic::Alembic) set_target_properties(abcdiff PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) INSTALL(TARGETS abcdiff DESTINATION bin) alembic-1.8.9/bin/AbcEcho/000077500000000000000000000000001507001531700151605ustar00rootroot00000000000000alembic-1.8.9/bin/AbcEcho/AbcBoundsEcho.cpp000066400000000000000000000137001507001531700203240ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2014, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include //-***************************************************************************** using namespace ::Alembic::AbcGeom; static Box3d g_bounds; //-***************************************************************************** void accumXform( M44d &xf, IObject obj, chrono_t seconds ) { if ( IXform::matches( obj.getHeader() ) ) { IXform x( obj ); XformSample xs; ISampleSelector sel( seconds ); x.getSchema().get( xs, sel ); xf *= xs.getMatrix(); } } //-***************************************************************************** M44d getFinalMatrix( IObject &iObj, chrono_t seconds ) { M44d xf; xf.makeIdentity(); IObject parent = iObj.getParent(); while ( parent ) { accumXform( xf, parent, seconds ); parent = parent.getParent(); } return xf; } //-***************************************************************************** Box3d getBounds( IObject iObj, chrono_t seconds ) { Box3d bnds; bnds.makeEmpty(); M44d xf = getFinalMatrix( iObj, seconds ); IBox3dProperty boxProp; if ( ICurves::matches( iObj.getMetaData() ) ) { ICurves curves( iObj ); ICurvesSchema cs = curves.getSchema(); boxProp = cs.getSelfBoundsProperty(); } else if ( INuPatch::matches( iObj.getMetaData() ) ) { INuPatch patch( iObj ); INuPatchSchema ps = patch.getSchema(); boxProp = ps.getSelfBoundsProperty(); } else if ( IPolyMesh::matches( iObj.getMetaData() ) ) { IPolyMesh mesh( iObj ); IPolyMeshSchema ms = mesh.getSchema(); boxProp = ms.getSelfBoundsProperty(); } else if ( IPoints::matches( iObj.getMetaData() ) ) { IPoints pts( iObj ); IPointsSchema ps = pts.getSchema(); boxProp = ps.getSelfBoundsProperty(); } else if ( ISubD::matches( iObj.getMetaData() ) ) { ISubD mesh( iObj ); ISubDSchema ms = mesh.getSchema(); boxProp = ms.getSelfBoundsProperty(); } if ( boxProp.valid() ) { ISampleSelector sel( seconds ); bnds = boxProp.getValue( sel ); bnds = Imath::transform( bnds, xf ); g_bounds.extendBy( bnds ); } g_bounds.extendBy( bnds ); return bnds; } //-***************************************************************************** void visitObject( IObject iObj, chrono_t seconds ) { std::string path = iObj.getFullName(); const MetaData &md = iObj.getMetaData(); if ( ICurves::matches( md ) || INuPatch::matches( md ) || IPoints::matches( md ) || IPolyMesh::matches( md ) || ISubDSchema::matches( md ) ) { Box3d bnds = getBounds( iObj, seconds ); std::cout << path << " " << bnds.min << " " << bnds.max << std::endl; } // now the child objects for ( size_t i = 0 ; i < iObj.getNumChildren() ; i++ ) { visitObject( IObject( iObj, iObj.getChildHeader( i ).getName() ), seconds ); } } //-***************************************************************************** //-***************************************************************************** // DO IT. //-***************************************************************************** //-***************************************************************************** int main( int argc, char *argv[] ) { if ( argc != 2 && argc != 3 ) { std::cerr << "USAGE: " << argv[0] << " " << std::endl; exit( -1 ); } chrono_t seconds = 0.0; if ( argc == 3 ) { seconds = atof(argv[2]); } // Scoped. g_bounds.makeEmpty(); { Alembic::AbcCoreFactory::IFactory factory; factory.setPolicy(ErrorHandler::kQuietNoopPolicy); IArchive archive = factory.getArchive( argv[1] ); visitObject( archive.getTop(), seconds ); } std::cout << "/" << " " << g_bounds.min << " " << g_bounds.max << std::endl; return 0; } alembic-1.8.9/bin/AbcEcho/AbcEcho.cpp000066400000000000000000000220121507001531700171450ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #include #include #include //-***************************************************************************** using namespace ::Alembic::AbcGeom; static const std::string g_sep( ";" ); //-***************************************************************************** // FORWARD void visitProperties( ICompoundProperty, std::string & ); //-***************************************************************************** template void visitSimpleArrayProperty( PROP iProp, const std::string &iIndent ) { std::string ptype = "ArrayProperty "; size_t asize = 0; AbcA::ArraySamplePtr samp; index_t maxSamples = iProp.getNumSamples(); for ( index_t i = 0 ; i < maxSamples; ++i ) { iProp.get( samp, ISampleSelector( i ) ); asize = samp->size(); }; std::string mdstring = "interpretation="; mdstring += iProp.getMetaData().get( "interpretation" ); std::stringstream dtype; dtype << "datatype="; dtype << iProp.getDataType(); std::stringstream asizestr; asizestr << ";arraysize="; asizestr << asize; mdstring += g_sep; mdstring += dtype.str(); mdstring += asizestr.str(); std::cout << iIndent << " " << ptype << "name=" << iProp.getName() << g_sep << mdstring << g_sep << "numsamps=" << iProp.getNumSamples() << std::endl; } //-***************************************************************************** template void visitSimpleScalarProperty( PROP iProp, const std::string &iIndent ) { std::string ptype = "ScalarProperty "; size_t asize = 0; const AbcA::DataType &dt = iProp.getDataType(); const Alembic::Util ::uint8_t extent = dt.getExtent(); Alembic::Util::Dimensions dims( extent ); AbcA::ArraySamplePtr samp = AbcA::AllocateArraySample( dt, dims ); index_t maxSamples = iProp.getNumSamples(); for ( index_t i = 0 ; i < maxSamples; ++i ) { iProp.get( const_cast( samp->getData() ), ISampleSelector( i ) ); asize = samp->size(); }; std::string mdstring = "interpretation="; mdstring += iProp.getMetaData().get( "interpretation" ); std::stringstream dtype; dtype << "datatype="; dtype << dt; std::stringstream asizestr; asizestr << ";arraysize="; asizestr << asize; mdstring += g_sep; mdstring += dtype.str(); mdstring += asizestr.str(); std::cout << iIndent << " " << ptype << "name=" << iProp.getName() << g_sep << mdstring << g_sep << "numsamps=" << iProp.getNumSamples() << std::endl; } //-***************************************************************************** void visitCompoundProperty( ICompoundProperty iProp, std::string &ioIndent ) { std::string oldIndent = ioIndent; ioIndent += " "; std::string interp = "schema="; interp += iProp.getMetaData().get( "schema" ); std::cout << ioIndent << "CompoundProperty " << "name=" << iProp.getName() << g_sep << interp << std::endl; visitProperties( iProp, ioIndent ); ioIndent = oldIndent; } //-***************************************************************************** void visitProperties( ICompoundProperty iParent, std::string &ioIndent ) { std::string oldIndent = ioIndent; for ( size_t i = 0 ; i < iParent.getNumProperties() ; i++ ) { PropertyHeader header = iParent.getPropertyHeader( i ); if ( header.isCompound() ) { visitCompoundProperty( ICompoundProperty( iParent, header.getName() ), ioIndent ); } else if ( header.isScalar() ) { visitSimpleScalarProperty( IScalarProperty( iParent, header.getName() ), ioIndent ); } else { assert( header.isArray() ); visitSimpleArrayProperty( IArrayProperty( iParent, header.getName() ), ioIndent ); } } ioIndent = oldIndent; } //-***************************************************************************** void visitObject( IObject iObj, std::string iIndent ) { // Object has a name, a full name, some meta data, // and then it has a compound property full of properties. std::string path = iObj.getFullName(); if ( path != "/" ) { std::cout << "Object " << "name=" << path << std::endl; } // Get the properties. ICompoundProperty props = iObj.getProperties(); visitProperties( props, iIndent ); // now the child objects for ( size_t i = 0 ; i < iObj.getNumChildren() ; i++ ) { visitObject( IObject( iObj, iObj.getChildHeader( i ).getName() ), iIndent ); } } //-***************************************************************************** //-***************************************************************************** // DO IT. //-***************************************************************************** //-***************************************************************************** int main( int argc, char *argv[] ) { if ( argc != 2 ) { std::cerr << "USAGE: " << argv[0] << " " << std::endl; exit( -1 ); } // Scoped. { Alembic::AbcCoreFactory::IFactory factory; factory.setPolicy(ErrorHandler::kQuietNoopPolicy); IArchive archive = factory.getArchive( argv[1] ); if (archive) { std::cout << "AbcEcho for " << Alembic::AbcCoreAbstract::GetLibraryVersion () << std::endl;; std::string appName; std::string libraryVersionString; Alembic::Util::uint32_t libraryVersion; std::string whenWritten; std::string userDescription; GetArchiveInfo (archive, appName, libraryVersionString, libraryVersion, whenWritten, userDescription); if (appName != "") { std::cout << " file written by: " << appName << std::endl; std::cout << " using Alembic : " << libraryVersionString << std::endl; std::cout << " written on : " << whenWritten << std::endl; std::cout << " user description : " << userDescription << std::endl; std::cout << std::endl; } else { std::cout << argv[1] << std::endl; std::cout << " (file doesn't have any ArchiveInfo)" << std::endl; std::cout << std::endl; } } visitObject( archive.getTop(), "" ); } return 0; } alembic-1.8.9/bin/AbcEcho/CMakeLists.txt000066400000000000000000000043031507001531700177200ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** ADD_EXECUTABLE(abcecho AbcEcho.cpp) TARGET_LINK_LIBRARIES(abcecho Alembic::Alembic) ADD_EXECUTABLE(abcechobounds AbcBoundsEcho.cpp) TARGET_LINK_LIBRARIES(abcechobounds Alembic::Alembic) set_target_properties(abcecho abcechobounds PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) INSTALL(TARGETS abcecho abcechobounds DESTINATION bin) alembic-1.8.9/bin/AbcLs/000077500000000000000000000000001507001531700146605ustar00rootroot00000000000000alembic-1.8.9/bin/AbcLs/AbcLs.cpp000066400000000000000000000717421507001531700163630ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif #include #include #include #include #include #include #include #include #include #include // no unistd under visual studio #ifndef _MSC_VER #include #endif #ifdef _MSC_VER #include // std::locale, std::isdigit // set up _S_ISDIR() #if !defined(S_ISDIR) # if defined( _S_IFDIR) && !defined( __S_IFDIR) # define __S_IFDIR _S_IFDIR # endif # define S_ISDIR(mode) (mode&__S_IFDIR) #endif #endif // _MSC_VER namespace Abc = ::Alembic::Abc; namespace AbcA = ::Alembic::AbcCoreAbstract; namespace AbcF = ::Alembic::AbcCoreFactory; namespace AbcG = ::Alembic::AbcGeom; namespace AbcU = ::Alembic::Util; using AbcA::index_t; #define RESETCOLOR "\033[0m" #define GRAYCOLOR "\033[1;30m" #define GREENCOLOR "\033[1;32m" #define BLUECOLOR "\033[1;34m" #define CYANCOLOR "\033[1;36m" #define REDCOLOR "\033[1;31m" #define BOLD "\033[1m" #define COL_1 20 #define COL_2 15 void segfault_sigaction(int signal) { std::cout << REDCOLOR << "Unrecoverable error: signal " << signal << RESETCOLOR << std::endl; exit(0); } //-***************************************************************************** // overload to print as a number instead of a character std::ostream & operator<<(std::ostream & os, Alembic::Util::uint8_t val) { return os << static_cast(val); } //-***************************************************************************** // overload to print as a number instead of a character std::ostream & operator<<(std::ostream & os, Alembic::Util::int8_t val) { return os << static_cast(val); } //-***************************************************************************** bool is_digit( const std::string& s ) { std::locale loc; std::string::const_iterator it = s.begin(); while (it != s.end() && std::isdigit(*it,loc)) ++it; return !s.empty() && it == s.end(); } //-***************************************************************************** void printTimeSampling( AbcA::TimeSamplingPtr iTime, index_t iMaxSample, double fps ) { AbcA::TimeSamplingType timeType = iTime->getTimeSamplingType(); if ( timeType.isUniform() ) { std::cout << "Uniform Sampling. Start time: " << iTime->getStoredTimes()[0] * fps << " Time per cycle: " << timeType.getTimePerCycle() * fps << std::endl; } else if ( timeType.isCyclic() ) { std::cout << "Cyclic Sampling. Time per cycle:" << timeType.getTimePerCycle() * fps << std::endl; const std::vector < double > & storedTimes = iTime->getStoredTimes(); std::size_t numTimes = iTime->getNumStoredTimes(); std::cout << "Start cycle times: "; for (std::size_t i = 0; i < numTimes; ++i ) { if (i != 0) { std::cout << ", "; } std::cout << storedTimes[i] * fps; } std:: cout << std::endl; } else { std::cout << "Acyclic Sampling." << std::endl; const std::vector < double > & storedTimes = iTime->getStoredTimes(); std::size_t numTimes = iTime->getNumStoredTimes(); for (std::size_t i = 0; i < numTimes; ++i ) { if (i != 0) { std::cout << ", "; } std::cout << storedTimes[i] * fps; } std:: cout << std::endl; } std::cout << "Max Num Samples: " << iMaxSample << std::endl; } //-***************************************************************************** void printParent( Abc::ICompoundProperty iProp, bool all = false, bool long_list = false, bool recursive = false, bool first = false ) { std::cout << CYANCOLOR << iProp.getObject().getFullName() << "/" << iProp.getName() << ":" << RESETCOLOR << std::endl; } //-***************************************************************************** void printParent( AbcG::IObject iObj, bool all = false, bool long_list = false, bool recursive = false, bool first = false ) { if ( !first && !long_list ) std::cout << std::endl; std::cout << CYANCOLOR << iObj.getFullName() << ":" << RESETCOLOR << std::endl; } //-***************************************************************************** void printMetaData( AbcA::MetaData md, bool all = false, bool long_list = false ) { std::stringstream ss( md.serialize() ); std::string segment; std::string spacing( COL_1, ' ' ); if ( long_list ) { if ( all ) spacing = std::string( COL_1 + COL_2, ' ' ); if ( md.size() == 1 ) { std::cout << GRAYCOLOR << " {" << md.serialize() << "}" << RESETCOLOR; } else if ( md.size() > 1 ) { std::cout << GRAYCOLOR << " {" << std::endl; while ( std::getline( ss, segment, ';' ) ) { std::cout << spacing << " " << segment << std::endl; } std::cout << spacing << "}" << RESETCOLOR; } } else { std::cout << GRAYCOLOR << " {" << md.serialize() << "} " << RESETCOLOR; } } //-***************************************************************************** template void getMetaData( Abc::ICompoundProperty iParent, Abc::PropertyHeader header, bool all = false, bool long_list = false ) { PROPERTY iProp( iParent, header.getName() ); printMetaData( iProp.getMetaData(), all, long_list ); } //-***************************************************************************** template void getScalarValue( Abc::IScalarProperty &p, const Abc::ISampleSelector &iSS ) { typedef typename TPTraits::value_type U; std::size_t extent = p.getDataType().getExtent(); std::vector< U > val( extent ); p.get( reinterpret_cast( &val.front() ), iSS ); std::string interp = p.getHeader().getMetaData().get("interpretation"); bool needsClose = false; std::size_t subExtent = 0; if (interp == "box") { std::cout << "Box("; needsClose = true; if (extent == 6) { subExtent = 3; } else if (extent == 4) { subExtent = 2; } } else if (interp == "rgb" || interp == "rbga") { std::cout << "Color("; needsClose = true; } else if (interp == "matrix" && extent == 9) { std::cout << "M33("; needsClose =true; subExtent = 3; } else if (interp == "matrix" && extent == 16) { std::cout << "M44("; needsClose =true; subExtent = 4; } for ( std::size_t i = 0; i < extent; ++i ) { if ( i != 0 ) { std::cout << ", "; } if ( subExtent != 0 && ( i % subExtent ) == 0) { std::cout << "("; } std::cout << val[i]; if ( subExtent != 0 && ( i % subExtent ) == subExtent - 1 ) { std::cout << ")"; } } if ( needsClose ) { std::cout << ")"; } std::cout << std::endl; } //-***************************************************************************** #define CASE_RETURN_SCALAR_VALUE( TPTraits, PROP, SELECTOR ) \ case TPTraits::pod_enum: \ return getScalarValue( PROP, SELECTOR ); //-***************************************************************************** template void getArrayValue( Abc::IArrayProperty &p, Abc::PropertyHeader &header, const Abc::ISampleSelector &iSS ) { Abc::DataType dt = header.getDataType(); AbcU ::uint8_t extent = dt.getExtent(); Abc::ArraySamplePtr ptr; p.get( ptr, iSS ); size_t totalValues = ptr->getDimensions().numPoints() * extent; TYPE *vals = (TYPE*)(ptr->getData()); for ( size_t i=0; i( PROP, HEADER, SELECTOR ); //-***************************************************************************** void printValue( Abc::ICompoundProperty iParent, Abc::PropertyHeader header, int index, bool justSize, bool printTime, double fps ) { Abc::ISampleSelector iss( (index_t) index ); Abc::DataType dt = header.getDataType(); AbcU::PlainOldDataType pod = dt.getPod(); AbcU ::uint8_t extent = dt.getExtent(); if ( header.isArray() ) { Abc::IArrayProperty p( iParent, header.getName() ); if ( printTime ) { std::cout << "Time: " << p.getTimeSampling()->getSampleTime( index ) * fps << std::endl; } if ( justSize ) { AbcU::Dimensions dims; p.getDimensions( dims, iss ); std::cout << "Extent: " << (int) extent << " Num points: " << dims.numPoints() << std::endl; return; } switch ( pod ) { CASE_RETURN_ARRAY_VALUE(Abc::BooleanTPTraits, bool, p, header, iss); CASE_RETURN_ARRAY_VALUE(Abc::Uint8TPTraits, uint8_t, p, header, iss); CASE_RETURN_ARRAY_VALUE(Abc::Int8TPTraits, int8_t, p, header, iss); CASE_RETURN_ARRAY_VALUE(Abc::Uint16TPTraits, uint16_t, p, header, iss); CASE_RETURN_ARRAY_VALUE(Abc::Int16TPTraits, int16_t, p, header, iss); CASE_RETURN_ARRAY_VALUE(Abc::Uint32TPTraits, uint32_t, p, header, iss); CASE_RETURN_ARRAY_VALUE(Abc::Int32TPTraits, int32_t, p, header, iss); CASE_RETURN_ARRAY_VALUE(Abc::Uint64TPTraits, uint64_t, p, header, iss); CASE_RETURN_ARRAY_VALUE(Abc::Int64TPTraits, int64_t, p, header, iss); CASE_RETURN_ARRAY_VALUE(Abc::Float32TPTraits, float, p, header, iss); CASE_RETURN_ARRAY_VALUE(Abc::Float64TPTraits, double, p, header, iss); CASE_RETURN_ARRAY_VALUE(Abc::StringTPTraits, std::string, p, header, iss); default: std::cout << "Unknown property type" << std::endl; break; } } else if ( header.isScalar() ) { Abc::IScalarProperty p( iParent, header.getName() ); if ( printTime ) { std::cout << "Time: " << p.getTimeSampling()->getSampleTime( index ) * fps << std::endl; } if ( justSize ) { std::cout << "Extent: " << (int) extent << std::endl; return; } switch ( pod ) { CASE_RETURN_SCALAR_VALUE( Abc::BooleanTPTraits, p, iss ); CASE_RETURN_SCALAR_VALUE( Abc::Uint8TPTraits, p, iss ); CASE_RETURN_SCALAR_VALUE( Abc::Int8TPTraits, p, iss ); CASE_RETURN_SCALAR_VALUE( Abc::Uint16TPTraits, p, iss ); CASE_RETURN_SCALAR_VALUE( Abc::Int16TPTraits, p, iss ); CASE_RETURN_SCALAR_VALUE( Abc::Uint32TPTraits, p, iss ); CASE_RETURN_SCALAR_VALUE( Abc::Int32TPTraits, p, iss ); CASE_RETURN_SCALAR_VALUE( Abc::Uint64TPTraits, p, iss ); CASE_RETURN_SCALAR_VALUE( Abc::Int64TPTraits, p, iss ); CASE_RETURN_SCALAR_VALUE( Abc::Float32TPTraits, p, iss ); CASE_RETURN_SCALAR_VALUE( Abc::Float64TPTraits, p, iss ); CASE_RETURN_SCALAR_VALUE( Abc::StringTPTraits, p, iss ); default: std::cout << "Unknown property type" << std::endl; break; } } } //-***************************************************************************** void printChild( Abc::ICompoundProperty iParent, Abc::PropertyHeader header, bool all = false, bool long_list = false, bool meta = false, bool values = false ) { std::string ptype; AbcA::MetaData md; if ( long_list ) { std::stringstream ss; if ( header.isCompound() ) { ptype = "CompoundProperty"; ss << ""; } else if ( header.isScalar() ) { ptype = "ScalarProperty"; ss << header.getDataType(); } else if ( header.isArray() ) { ptype = "ArrayProperty"; ss << header.getDataType(); } std::cout << ptype << std::string( COL_1 - ptype.length(), ' ' ) << ss.str() << std::string( COL_2 - ss.str().length(), ' ' ); } std::cout << BLUECOLOR << header.getName(); if ( long_list ) { if ( header.isScalar() ) { Abc::IScalarProperty iProp( iParent, header.getName() ); std::cout << "[" << iProp.getNumSamples() << "]"; } else if ( header.isArray() ) { Abc::IArrayProperty iProp( iParent, header.getName() ); std::cout << "[" << iProp.getNumSamples() << "]"; } if ( meta ) { if ( header.isCompound() ) getMetaData( iParent, header, all, long_list ); else if ( header.isScalar() ) getMetaData( iParent, header, all, long_list ); else if ( header.isArray() ) getMetaData( iParent, header, all, long_list ); } std::cout << std::endl; } else std::cout << " "; // try to access and print the 0th sample value if ( values && !header.isCompound() ) { try { printValue( iParent, header, 0, false, false, 24.0 ); } catch ( std::exception& e ) { std::cerr << "Exception : " << e.what() << std::endl; } } std::cout << RESETCOLOR; } //-***************************************************************************** void printChild( AbcG::IObject iParent, AbcG::IObject iObj, bool all = false, bool long_list = false, bool meta = false, bool values = false ) { AbcA::MetaData md = iObj.getMetaData(); if ( long_list ) { std::string schema = md.get( "schema" ); size_t spacing = COL_1; if ( all ) spacing = COL_1 + COL_2; if (spacing > schema.length()) std::cout << schema << std::string(spacing - schema.length(), ' '); else std::cout << schema; } std::cout << GREENCOLOR << iObj.getName(); if ( meta ) printMetaData( md, all, long_list ); std::cout << RESETCOLOR; if ( long_list ) std::cout << std::endl; else std::cout << " "; } //-***************************************************************************** void visit( Abc::ICompoundProperty iProp, bool all = false, bool long_list = false, bool meta = false, bool recursive = false, bool first = false, bool values = false ) { // header if ( recursive && iProp.getNumProperties() > 0 ) { printParent( iProp, all, long_list, recursive, first ); } // children for( size_t c = 0; c < iProp.getNumProperties(); ++c ) { printChild( iProp, iProp.getPropertyHeader( c ), all, long_list, meta, values ); } // visit children if ( recursive && all && iProp.getNumProperties() > 0 ) { for( size_t p = 0; p < iProp.getNumProperties(); ++p ) { Abc::PropertyHeader header = iProp.getPropertyHeader( p ); if ( header.isCompound() ) visit( Abc::ICompoundProperty( iProp, header.getName() ), all, long_list, meta, recursive, false, values ); } } } //-***************************************************************************** void visit( AbcG::IObject iObj, bool all = false, bool long_list = false, bool meta = false, bool recursive = false, bool first = false, bool values = false ) { Abc::ICompoundProperty props = iObj.getProperties(); // header if ( recursive && ( iObj.getNumChildren() > 0 || ( all && props.getNumProperties() > 0 ) ) ) { printParent( iObj, all, long_list, recursive, first ); } // children for( size_t c = 0; c < iObj.getNumChildren(); ++c ) { printChild( iObj, iObj.getChild( c ), all, long_list, meta, values ); } // properties if ( all ) { for( size_t h = 0; h < props.getNumProperties(); ++h ) { printChild( props, props.getPropertyHeader( h ), all, long_list, meta, values ); } } // visit property children if ( recursive && all && props.getNumProperties() > 0 ) { for( size_t p = 0; p < props.getNumProperties(); ++p ) { Abc::PropertyHeader header = props.getPropertyHeader( p ); if ( header.isCompound() ) { if ( !long_list ) std::cout << std::endl; visit( Abc::ICompoundProperty( props, header.getName() ), all, long_list, meta, recursive, false, values ); } } } // visit object children if ( recursive && iObj.getNumChildren() > 0 ) { for( size_t c = 0; c < iObj.getNumChildren(); ++c ) { visit( iObj.getChild( c ), all, long_list, meta, recursive, false, values ); } } } //-***************************************************************************** bool isFile( const std::string& filename ) { struct stat buf; if ( stat(filename.c_str(), &buf) == 0 && !S_ISDIR( buf.st_mode ) ) { return true; } return false; } //-***************************************************************************** bool optionExists(std::vector options, std::string option) { for ( std::size_t i = 0; i < options.size(); i++ ) if ( options[i].find(option) != std::string::npos ) return true; return false; } //-***************************************************************************** int main( int argc, char *argv[] ) { //float opt_fps = 24.0; bool opt_all = false; // show all option bool opt_long = false; // long listing option bool opt_meta = false; // metadata option bool opt_recursive = false; // recursive option bool opt_size = false; // array sample size option bool opt_time = false; // time info option bool opt_values = false; // show all 0th values int index = -1; // sample number, at tail of path std::string desc( "abcls [OPTION] FILE[/NAME] \n" " -a include property listings\n" " -f show time sampling as 24 fps\n" " -h, --help show this help message\n" " -l long listing format\n" " -m show archive metadata\n" " -r list entries recursively\n" " -s show the size of a data property sample\n" " -t show time sampling information\n" " -v show 0th value for all properties\n" ); /* sigaction if available */ #if defined(_POSIX_VERSION) && (_POSIX_VERSION >= 199506L) // seg fault handler struct sigaction act; sigemptyset(&act.sa_mask); act.sa_handler = segfault_sigaction; act.sa_flags = SA_SIGINFO; sigaction(SIGSEGV, &act, NULL); /* signal if available */ #elif defined(_POSIX_VERSION) || defined(_MSC_VER) || defined(__MINGW32__) signal(SIGSEGV, segfault_sigaction); #else #error No signal interface available #endif //_POSIX_VERSION // check for min args if ( argc < 2 ) { std::cout << desc << std::endl; return 0; }; // parse args std::vector arguments(argv, argv + argc); std::vector options; std::vector files; // separate file args from option args for ( std::size_t i = 1; i < arguments.size(); i++ ) { if ( arguments[ i ].substr( 0, 1 ) == "-" ) options.push_back( arguments[ i ] ); else files.push_back( arguments[ i ] ); } // help if ( argc < 2 || optionExists( options, "h" ) || optionExists( options, "help" ) ) { std::cout << desc << std::endl; return 0; }; // set some flags double fps = 1.0; opt_all = optionExists( options, "a" ); opt_long = optionExists( options, "l" ); opt_meta = optionExists( options, "m" ); opt_recursive = optionExists( options, "r" ); opt_size = optionExists( options, "s" ); opt_time = optionExists( options, "t" ); opt_values = optionExists( options, "v" ); if ( optionExists( options, "f" ) ) { fps = 24.0; opt_time = true; } // open each file for ( std::size_t i = 0; i < files.size(); i++ ) { if ( files.size() > 1 ) std::cout << BOLD << files[i] << ':' << RESETCOLOR << std::endl; std::stringstream ss( files[i] ); std::stringstream fp; std::string segment; std::vector seglist; /* * separate file and object paths, e.g. * * ../dir1/foo.abc/bar/baz/index * \_____________/\______/\____/ * file obj sample */ int j = 0; while ( std::getline( ss, segment, '/' ) ) { if ( !isFile ( fp.str() ) ) { if ( j != 0 ) fp << "/"; fp << segment; } else { seglist.push_back( segment ); } ++j; } bool lastIsIndex = false; if (!seglist.empty() && is_digit( seglist.back() ) ) { index = atoi( seglist.back().c_str() ); lastIsIndex = true; } // open the iarchive Abc::IArchive archive; AbcF::IFactory factory; factory.setPolicy(Abc::ErrorHandler::kQuietNoopPolicy); AbcF::IFactory::CoreType coreType; archive = factory.getArchive(std::string( fp.str() ), coreType); // display file metadata if ( opt_meta && seglist.size() == 0 ) { std::cout << "Using " << Alembic::AbcCoreAbstract::GetLibraryVersion() << std::endl;; std::string appName; std::string libraryVersionString; Alembic::Util::uint32_t libraryVersion; std::string whenWritten; std::string userDescription; std::string coreName; double dccFps; GetArchiveInfo (archive, appName, libraryVersionString, libraryVersion, whenWritten, userDescription, dccFps); if ( coreType == AbcF::IFactory::kOgawa ) { coreName = "Ogawa"; } else if ( coreType == AbcF::IFactory::kHDF5 ) { coreName = "HDF5"; } else { coreName = "Unknown"; }; if ( appName != "" ) { std::cout << " file written by: " << appName << std::endl; std::cout << " using Alembic : " << libraryVersionString << std::endl; std::cout << " written on : " << whenWritten << std::endl; std::cout << " user description : " << userDescription << std::endl; if (dccFps > 0) { std::cout << " DCC FPS at write: " << dccFps << std::endl; } } else { std::cout << " (file doesn't have any ArchiveInfo)" << std::endl; } std::cout << " core type : " << coreName << std::endl; }; if ( opt_time && seglist.size() == 0 ) { uint32_t numTimes = archive.getNumTimeSamplings(); std::cout << std::endl << "Time Samplings: " << std::endl; for ( uint32_t k = 0; k < numTimes; ++k ) { AbcA::TimeSamplingPtr ts = archive.getTimeSampling( k ); index_t maxSample = archive.getMaxNumSamplesForTimeSamplingIndex( k ); std::cout << k << " "; printTimeSampling( ts, maxSample, fps ); } std::cout << std::endl; } // walk object hierarchy and find valid objects AbcG::IObject test = archive.getTop(); AbcG::IObject iObj = test; while ( test.valid() && seglist.size() > 0 ) { test = test.getChild( seglist.front() ); if ( test.valid() ) { iObj = test; seglist.erase( seglist.begin() ); } } // walk property hierarchy for most recent object Abc::ICompoundProperty props = iObj.getProperties(); const Abc::PropertyHeader* header = NULL; bool found = false; bool shouldPrintValue = false; for ( std::size_t i = 0; i < seglist.size(); ++i ) { header = props.getPropertyHeader( seglist[i] ); if ( header && header->isCompound() ) { Abc::ICompoundProperty ptest( props, header->getName() ); if ( ptest.valid() ) { props = ptest; found = true; } } else if ( header && header->isSimple() ) { found = true; // if the last value happens to be an index, and we are a // property then dont bother checking the last item in seglist if (lastIsIndex && i == seglist.size() - 2) { shouldPrintValue = true; break; } } else { std::cout << seglist[i] << ": Invalid object or property" << std::endl; return 1; } } // do stuff if ( shouldPrintValue ) { printValue( props, *header, index, opt_size, opt_time, fps ); } else { if ( found && header->isCompound() ) visit( props, opt_all, opt_long, opt_meta, opt_recursive, true, opt_values ); else if ( found && header->isSimple() ) printChild( props, *header, opt_all, opt_long, opt_values ); else visit( iObj, opt_all, opt_long, opt_meta, opt_recursive, true, opt_values ); std::cout << RESETCOLOR; if ( !opt_long ) std::cout << std::endl; } } return 0; } alembic-1.8.9/bin/AbcLs/CMakeLists.txt000066400000000000000000000040671507001531700174270ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2013-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** ADD_EXECUTABLE(abcls AbcLs.cpp) TARGET_LINK_LIBRARIES(abcls Alembic::Alembic) set_target_properties(abcls PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) INSTALL(TARGETS abcls DESTINATION bin) alembic-1.8.9/bin/AbcStitcher/000077500000000000000000000000001507001531700160675ustar00rootroot00000000000000alembic-1.8.9/bin/AbcStitcher/AbcStitcher.cpp000066400000000000000000001271441507001531700207770ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2014, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #ifdef ALEMBIC_WITH_HDF5 #include #endif #include #include #include "util.h" #include #include #include #include #include using namespace Alembic::AbcGeom; using namespace Alembic::AbcCoreAbstract; namespace{ inline void stitchVisible(ICompoundPropertyVec & iCompoundProps, OCompoundProperty & oCompoundProp, const TimeAndSamplesMap & iTimeMap) { const PropertyHeader * propHeaderPtr = iCompoundProps[0].getPropertyHeader("visible"); stitchScalarProp(*propHeaderPtr, iCompoundProps, oCompoundProp, iTimeMap); } template< class IPARAM, class IPARAMSAMP, class OPARAMSAMP > void getOGeomParamSamp(IPARAM & iGeomParam, IPARAMSAMP & iGeomSamp, OPARAMSAMP & oGeomSamp, index_t iIndex) { if (iGeomParam.isIndexed()) { iGeomParam.getIndexed(iGeomSamp, iIndex); oGeomSamp.setVals(*(iGeomSamp.getVals())); oGeomSamp.setScope(iGeomSamp.getScope()); oGeomSamp.setIndices(*(iGeomSamp.getIndices())); } else { iGeomParam.getExpanded(iGeomSamp, iIndex); oGeomSamp.setVals(*(iGeomSamp.getVals())); oGeomSamp.setScope(iGeomSamp.getScope()); } } template< class IData, class IDataSchema, class OData, class ODataSchema > void init(std::vector< IObject > & iObjects, OObject & oParentObj, ODataSchema & oSchema, const TimeAndSamplesMap & iTimeMap, std::size_t & oTotalSamples) { // find the first valid IObject IObject inObj; for (std::size_t i = 0; i < iObjects.size(); ++i) { if (iObjects[i].valid()) { inObj = iObjects[i]; break; } } const std::string fullNodeName = inObj.getFullName(); // gather information from the first input node in the list: IDataSchema iSchema0 = IData(inObj).getSchema(); TimeSamplingPtr tsPtr0 = iTimeMap.get(iSchema0.getTimeSampling(), oTotalSamples); TimeSamplingType tsType0 = tsPtr0->getTimeSamplingType(); checkAcyclic(tsType0, fullNodeName); ICompoundPropertyVec iCompoundProps; iCompoundProps.reserve(iObjects.size()); ICompoundPropertyVec iArbGeomCompoundProps; iArbGeomCompoundProps.reserve(iObjects.size()); ICompoundPropertyVec iUserCompoundProps; iUserCompoundProps.reserve(iObjects.size()); ICompoundPropertyVec iSchemaProps; iSchemaProps.reserve(iObjects.size()); Abc::IBox3dProperty childBounds = iSchema0.getChildBoundsProperty(); TimeSamplingPtr ctsPtr0; TimeSamplingType ctsType0; if (childBounds) { ctsPtr0 = childBounds.getTimeSampling(); ctsType0 = ctsPtr0->getTimeSamplingType(); std::string nameAndBounds = fullNodeName + " child bounds"; checkAcyclic(ctsType0, nameAndBounds); } bool hasVisible = inObj.getProperties().getPropertyHeader("visible") != NULL; // sanity check (no frame range checking here) // - timesamplying type has to be the same and can't be acyclic for (size_t i = 0; i < iObjects.size(); i++) { if (!iObjects[i].valid()) { continue; } IDataSchema iSchema = IData(iObjects[i]).getSchema(); TimeSamplingPtr tsPtr = iSchema.getTimeSampling(); TimeSamplingType tsType = tsPtr->getTimeSamplingType(); checkAcyclic(tsType, fullNodeName); if (!(tsType0 == tsType)) { std::cerr << "Can not stitch different sampling type for node \"" << fullNodeName << "\"" << std::endl; // more details on this if (tsType.getNumSamplesPerCycle() != tsType0.getNumSamplesPerCycle()) { std::cerr << "\tnumSamplesPerCycle values are different" << std::endl; } if (tsType.getTimePerCycle() != tsType0.getTimePerCycle()) { std::cerr << "\ttimePerCycle values are different" << std::endl; } exit(1); } ICompoundProperty cp = iObjects[i].getProperties(); iCompoundProps.push_back(cp); ICompoundProperty arbProp = iSchema.getArbGeomParams(); if (arbProp) // might be empty iArbGeomCompoundProps.push_back(arbProp); ICompoundProperty userProp = iSchema.getUserProperties(); if (userProp) // might be empty iUserCompoundProps.push_back(userProp); Abc::IBox3dProperty childBounds = iSchema.getChildBoundsProperty(); TimeSamplingPtr ctsPtr; TimeSamplingType ctsType; if (childBounds) { ctsPtr = childBounds.getTimeSampling(); ctsType = ctsPtr->getTimeSamplingType(); iSchemaProps.push_back(iSchema); } if (!(ctsType0 == ctsType)) { std::cerr << "Can not stitch different sampling type for child bounds on\"" << fullNodeName << "\"" << std::endl; // more details on this if (ctsType.getNumSamplesPerCycle() != ctsType0.getNumSamplesPerCycle()) { std::cerr << "\tnumSamplesPerCycle values are different" << std::endl; } if (ctsType.getTimePerCycle() != ctsType0.getTimePerCycle()) { std::cerr << "\ttimePerCycle values are different" << std::endl; } if (!ctsPtr0 || !ctsPtr) { std::cerr << "\tchild bounds are missing on some archives" << std::endl; } exit(1); } } OData oData(oParentObj, inObj.getName(), tsPtr0); oSchema = oData.getSchema(); // stitch "visible" if it's points // if (hasVisible) { OCompoundProperty oCompoundProp = oData.getProperties(); stitchVisible(iCompoundProps, oCompoundProp, iTimeMap); } // stitch ArbGeomParams and User Properties // if (iArbGeomCompoundProps.size() == iObjects.size()) { OCompoundProperty oArbGeomCompoundProp = oSchema.getArbGeomParams(); stitchCompoundProp(iArbGeomCompoundProps, oArbGeomCompoundProp, iTimeMap); } if (iUserCompoundProps.size() == iObjects.size()) { OCompoundProperty oUserCompoundProp = oSchema.getUserProperties(); stitchCompoundProp(iUserCompoundProps, oUserCompoundProp, iTimeMap); } if (!iSchemaProps.empty()) { stitchScalarProp(childBounds.getHeader(), iSchemaProps, oSchema, iTimeMap); } } }; //-***************************************************************************** // a recursive function that reads all inputs and write to the given oObject // node if there's no gap in the frame range for animated nodes // void visitObjects(std::vector< IObject > & iObjects, OObject & oParentObj, const TimeAndSamplesMap & iTimeMap, bool atRoot) { OObject outObj; IObject inObj; std::vector< IObject >::iterator it; for (it = iObjects.begin(); it != iObjects.end(); ++it) { if (it->valid()) { inObj = *it; break; } } assert(inObj.valid()); if (iTimeMap.isVerbose()) { std::cout << inObj.getFullName() << std::endl; } const AbcA::ObjectHeader & header = inObj.getHeader(); std::size_t totalSamples = 0; // keep track of how many we have set so far to work around issue 430 std::size_t totalSet = 0; // there are a number of things that needs to be checked for each node // to make sure they can be properly stitched together // // for xform node: // locator or normal xform node // if an xform node, numOps and type of ops match // static or no, and if not, timesampling type matches // if sampled, timesampling type should match // if sampled, no frame gaps // if (IXform::matches(header)) { OXformSchema oSchema; init< IXform, IXformSchema, OXform, OXformSchema >( iObjects, oParentObj, oSchema, iTimeMap, totalSamples); outObj = oSchema.getObject(); ICompoundPropertyVec iCompoundProps; iCompoundProps.reserve(iObjects.size()); const PropertyHeader * locHeader = NULL; for (size_t i = 0; i < iObjects.size(); i++) { if (!iObjects[i].valid()) { iCompoundProps.push_back(ICompoundProperty()); continue; } ICompoundProperty cp = iObjects[i].getProperties(); iCompoundProps.push_back(cp); const PropertyHeader * childLocHeader = cp.getPropertyHeader("locator"); if (!locHeader && childLocHeader) { locHeader = childLocHeader; } } // stitch the operations if this is an xform node size_t i = 0; for (i = 0; i < iObjects.size(); i++) { if (!iObjects[i].valid()) { continue; } IXformSchema iSchema = IXform(iObjects[i]).getSchema(); index_t numSamples = iSchema.getNumSamples(); index_t numEmpty = 0; index_t reqIdx = getIndexSample(totalSet, oSchema.getTimeSampling(), numSamples, iSchema.getTimeSampling(), numEmpty); // write empties only if we are also writing a sample, as the // first sample will be repeated over and over again for (index_t emptyIdx = 0; reqIdx < numSamples && emptyIdx < numEmpty; ++emptyIdx) { XformSample samp = iSchema.getValue(reqIdx); oSchema.set(samp); } totalSet += numEmpty; for (; reqIdx < numSamples; reqIdx++, totalSet++) { XformSample samp = iSchema.getValue(reqIdx); oSchema.set(samp); } } // make sure we've set a sample, if we are going to extend them for (i = totalSet; i != 0 && i < totalSamples; ++i) { oSchema.setFromPrevious(); } // stitch "locator" if it's a locator OCompoundProperty oCompoundProp = outObj.getProperties(); if (locHeader) { stitchScalarProp(*locHeader, iCompoundProps, oCompoundProp, iTimeMap); } } else if (ISubD::matches(header)) { OSubDSchema oSchema; init< ISubD, ISubDSchema, OSubD, OSubDSchema >( iObjects, oParentObj, oSchema, iTimeMap, totalSamples); outObj = oSchema.getObject(); OSubDSchema::Sample emptySample(P3fArraySample::emptySample(), Int32ArraySample::emptySample(), Int32ArraySample::emptySample()); // stitch the SubDSchema // for (size_t i = 0; i < iObjects.size(); i++) { if (!iObjects[i].valid()) { continue; } ISubDSchema iSchema = ISubD(iObjects[i]).getSchema(); index_t numSamples = iSchema.getNumSamples(); IV2fGeomParam uvs = iSchema.getUVsParam(); if (totalSet == 0 && uvs) { oSchema.setUVSourceName(GetSourceName(uvs.getMetaData())); } index_t numEmpty = 0; index_t reqIdx = getIndexSample(totalSet, oSchema.getTimeSampling(), numSamples, iSchema.getTimeSampling(), numEmpty); // not hold, then set empties, other set previous if we have previous samples if (!iTimeMap.isHold() || totalSet > 0) { for (index_t emptyIdx = 0; emptyIdx < numEmpty; ++emptyIdx) { if (!iTimeMap.isHold()) { oSchema.set(emptySample); } else { oSchema.setFromPrevious(); } } totalSet += numEmpty; } for (; reqIdx < numSamples; reqIdx++, totalSet++) { ISubDSchema::Sample iSamp = iSchema.getValue(reqIdx); OSubDSchema::Sample oSamp; Abc::P3fArraySamplePtr posPtr = iSamp.getPositions(); if (posPtr) oSamp.setPositions(*posPtr); Abc::V3fArraySamplePtr velocPtr = iSamp.getVelocities(); if (velocPtr) oSamp.setVelocities(*velocPtr); Abc::Int32ArraySamplePtr faceIndicesPtr = iSamp.getFaceIndices(); if (faceIndicesPtr) oSamp.setFaceIndices(*faceIndicesPtr); Abc::Int32ArraySamplePtr faceCntPtr = iSamp.getFaceCounts(); if (faceCntPtr) oSamp.setFaceCounts(*faceCntPtr); oSamp.setFaceVaryingInterpolateBoundary(iSamp.getFaceVaryingInterpolateBoundary()); oSamp.setFaceVaryingPropagateCorners(iSamp.getFaceVaryingPropagateCorners()); oSamp.setInterpolateBoundary(iSamp.getInterpolateBoundary()); Abc::Int32ArraySamplePtr creaseIndicesPtr = iSamp.getCreaseIndices(); if (creaseIndicesPtr) oSamp.setCreaseIndices(*creaseIndicesPtr); Abc::Int32ArraySamplePtr creaseLenPtr = iSamp.getCreaseLengths(); if (creaseLenPtr) oSamp.setCreaseLengths(*creaseLenPtr); Abc::FloatArraySamplePtr creaseSpPtr = iSamp.getCreaseSharpnesses(); if (creaseSpPtr) oSamp.setCreaseSharpnesses(*creaseSpPtr); Abc::Int32ArraySamplePtr cornerIndicesPtr = iSamp.getCornerIndices(); if (cornerIndicesPtr) oSamp.setCornerIndices(*cornerIndicesPtr); Abc::FloatArraySamplePtr cornerSpPtr = iSamp.getCornerSharpnesses(); if (cornerSpPtr) oSamp.setCornerSharpnesses(*cornerSpPtr); Abc::Int32ArraySamplePtr holePtr = iSamp.getHoles(); if (holePtr) oSamp.setHoles(*holePtr); oSamp.setSubdivisionScheme(iSamp.getSubdivisionScheme()); // set uvs IV2fGeomParam::Sample iUVSample; OV2fGeomParam::Sample oUVSample; if (uvs) { getOGeomParamSamp (uvs, iUVSample, oUVSample, reqIdx); oSamp.setUVs(oUVSample); } oSchema.set(oSamp); // our first sample was written, AND we want to hold so set our previous samples to this one! if (iTimeMap.isHold() && totalSet == 0) { for (index_t emptyIdx = 0; emptyIdx < numEmpty; ++emptyIdx) { oSchema.setFromPrevious(); } totalSet += numEmpty; } } } for (size_t i = totalSet; i < totalSamples; ++i) { if (!iTimeMap.isHold()) { oSchema.set(emptySample); } else { oSchema.setFromPrevious(); } } } else if (IPolyMesh::matches(header)) { OPolyMeshSchema oSchema; init< IPolyMesh, IPolyMeshSchema, OPolyMesh, OPolyMeshSchema >( iObjects, oParentObj, oSchema, iTimeMap, totalSamples); outObj = oSchema.getObject(); OPolyMeshSchema::Sample emptySample(P3fArraySample::emptySample(), Int32ArraySample::emptySample(), Int32ArraySample::emptySample()); // stitch the PolySchema // for (size_t i = 0; i < iObjects.size(); i++) { if (!iObjects[i].valid()) { continue; } IPolyMeshSchema iSchema = IPolyMesh(iObjects[i]).getSchema(); index_t numSamples = iSchema.getNumSamples(); IN3fGeomParam normals = iSchema.getNormalsParam(); IV2fGeomParam uvs = iSchema.getUVsParam(); if (totalSet == 0 && uvs) { oSchema.setUVSourceName(GetSourceName(uvs.getMetaData())); } index_t numEmpty = 0; index_t reqIdx = getIndexSample(totalSet, oSchema.getTimeSampling(), numSamples, iSchema.getTimeSampling(), numEmpty); // not hold, then set empties, other set previous if we have previous samples if (!iTimeMap.isHold() || totalSet > 0) { for (index_t emptyIdx = 0; emptyIdx < numEmpty; ++emptyIdx) { if (!iTimeMap.isHold()) { oSchema.set(emptySample); } else { oSchema.setFromPrevious(); } } totalSet += numEmpty; } for (; reqIdx < numSamples; reqIdx++, totalSet++) { IPolyMeshSchema::Sample iSamp = iSchema.getValue(reqIdx); OPolyMeshSchema::Sample oSamp; Abc::P3fArraySamplePtr posPtr = iSamp.getPositions(); if (posPtr) oSamp.setPositions(*posPtr); Abc::V3fArraySamplePtr velocPtr = iSamp.getVelocities(); if (velocPtr) oSamp.setVelocities(*velocPtr); Abc::Int32ArraySamplePtr faceIndicesPtr = iSamp.getFaceIndices(); if (faceIndicesPtr) oSamp.setFaceIndices(*faceIndicesPtr); Abc::Int32ArraySamplePtr faceCntPtr = iSamp.getFaceCounts(); if (faceCntPtr) oSamp.setFaceCounts(*faceCntPtr); // set uvs IV2fGeomParam::Sample iUVSample; OV2fGeomParam::Sample oUVSample; if (uvs) { getOGeomParamSamp (uvs, iUVSample, oUVSample, reqIdx); oSamp.setUVs(oUVSample); } // set normals IN3fGeomParam::Sample iNormalsSample; ON3fGeomParam::Sample oNormalsSample; if (normals) { getOGeomParamSamp (normals, iNormalsSample, oNormalsSample, reqIdx); oSamp.setNormals(oNormalsSample); } oSchema.set(oSamp); // our first sample was written, AND we want to hold so set our previous samples to this one! if (iTimeMap.isHold() && totalSet == 0) { for (index_t emptyIdx = 0; emptyIdx < numEmpty; ++emptyIdx) { oSchema.setFromPrevious(); } totalSet += numEmpty; } } } for (size_t i = totalSet; i < totalSamples; ++i) { if (!iTimeMap.isHold()) { oSchema.set(emptySample); } else { oSchema.setFromPrevious(); } } } else if (ICamera::matches(header)) { OCameraSchema oSchema; init< ICamera, ICameraSchema, OCamera, OCameraSchema >( iObjects, oParentObj, oSchema, iTimeMap, totalSamples); outObj = oSchema.getObject(); // stitch the CameraSchemas, we dont need to worry about isHold // because we set from previous here for (size_t i = 0; i < iObjects.size(); i++) { if (!iObjects[i].valid()) { continue; } ICameraSchema iSchema = ICamera(iObjects[i]).getSchema(); index_t numSamples = iSchema.getNumSamples(); index_t numEmpty = 0; index_t reqIdx = getIndexSample(totalSet, oSchema.getTimeSampling(), numSamples, iSchema.getTimeSampling(), numEmpty); // write empties only if we are also writing a sample, as the // first sample will be repeated over and over again for (index_t emptyIdx = 0; reqIdx < numSamples && emptyIdx < numEmpty; ++emptyIdx) { oSchema.set(iSchema.getValue(reqIdx)); } totalSet += numEmpty; for (; reqIdx < numSamples; reqIdx++, totalSet++) { oSchema.set(iSchema.getValue(reqIdx)); } } // for the rest of the samples just set the last one as long as // a sample has been already set for (size_t i = totalSet; i != 0 && i < totalSamples;++i) { oSchema.setFromPrevious(); } } else if (ICurves::matches(header)) { OCurvesSchema oSchema; init< ICurves, ICurvesSchema, OCurves, OCurvesSchema >( iObjects, oParentObj, oSchema, iTimeMap, totalSamples); outObj = oSchema.getObject(); OCurvesSchema::Sample emptySample(P3fArraySample::emptySample(), Int32ArraySample::emptySample()); // stitch the CurvesSchemas // for (size_t i = 0; i < iObjects.size(); i++) { if (!iObjects[i].valid()) { continue; } ICurvesSchema iSchema = ICurves(iObjects[i]).getSchema(); IV2fGeomParam iUVs = iSchema.getUVsParam(); IN3fGeomParam iNormals = iSchema.getNormalsParam(); IFloatGeomParam iWidths = iSchema.getWidthsParam(); IFloatArrayProperty iKnots = iSchema.getKnotsProperty(); IUcharArrayProperty iOrders = iSchema.getOrdersProperty(); index_t numSamples = iSchema.getNumSamples(); index_t numEmpty = 0; index_t reqIdx = getIndexSample(totalSet, oSchema.getTimeSampling(), numSamples, iSchema.getTimeSampling(), numEmpty); // not hold, then set empties, other set previous if we have previous samples if (!iTimeMap.isHold() || totalSet > 0) { for (index_t emptyIdx = 0; emptyIdx < numEmpty; ++emptyIdx) { if (!iTimeMap.isHold()) { oSchema.set(emptySample); } else { oSchema.setFromPrevious(); } } totalSet += numEmpty; } for (; reqIdx < numSamples; reqIdx++, totalSet++) { ICurvesSchema::Sample iSamp = iSchema.getValue(reqIdx); OCurvesSchema::Sample oSamp; Abc::P3fArraySamplePtr posPtr = iSamp.getPositions(); if (posPtr) oSamp.setPositions(*posPtr); Abc::V3fArraySamplePtr velocPtr = iSamp.getVelocities(); if (velocPtr) oSamp.setVelocities(*velocPtr); oSamp.setType(iSamp.getType()); Abc::Int32ArraySamplePtr curvsNumPtr = iSamp.getCurvesNumVertices(); if (curvsNumPtr) oSamp.setCurvesNumVertices(*curvsNumPtr); oSamp.setWrap(iSamp.getWrap()); oSamp.setBasis(iSamp.getBasis()); Abc::FloatArraySamplePtr knotsPtr = iSamp.getKnots(); if (knotsPtr) { oSamp.setKnots(*knotsPtr); } Abc::UcharArraySamplePtr ordersPtr = iSamp.getOrders(); if (ordersPtr) { oSamp.setOrders(*ordersPtr); } IFloatGeomParam::Sample iWidthSample; OFloatGeomParam::Sample oWidthSample; if (iWidths) { getOGeomParamSamp (iWidths, iWidthSample, oWidthSample, reqIdx); oSamp.setWidths(oWidthSample); } IV2fGeomParam::Sample iUVSample; OV2fGeomParam::Sample oUVSample; if (iUVs) { getOGeomParamSamp (iUVs, iUVSample, oUVSample, reqIdx); oSamp.setUVs(oUVSample); } IN3fGeomParam::Sample iNormalsSample; ON3fGeomParam::Sample oNormalsSample; if (iNormals) { getOGeomParamSamp (iNormals, iNormalsSample, oNormalsSample, reqIdx); oSamp.setNormals(oNormalsSample); } oSchema.set(oSamp); // our first sample was written, AND we want to hold so set our previous samples to this one! if (iTimeMap.isHold() && totalSet == 0) { for (index_t emptyIdx = 0; emptyIdx < numEmpty; ++emptyIdx) { oSchema.setFromPrevious(); } totalSet += numEmpty; } } } for (size_t i = totalSet; i < totalSamples; ++i) { if (!iTimeMap.isHold()) { oSchema.set(emptySample); } else { oSchema.setFromPrevious(); } } } else if (IPoints::matches(header)) { OPointsSchema oSchema; init< IPoints, IPointsSchema, OPoints, OPointsSchema >( iObjects, oParentObj, oSchema, iTimeMap, totalSamples); outObj = oSchema.getObject(); OPointsSchema::Sample emptySample(P3fArraySample::emptySample(), UInt64ArraySample::emptySample()); // stitch the PointsSchemas // for (size_t i = 0; i < iObjects.size(); i++) { if (!iObjects[i].valid()) { continue; } IPointsSchema iSchema = IPoints(iObjects[i]).getSchema(); IFloatGeomParam iWidths = iSchema.getWidthsParam(); index_t numSamples = iSchema.getNumSamples(); index_t numEmpty = 0; index_t reqIdx = getIndexSample(totalSet, oSchema.getTimeSampling(), numSamples, iSchema.getTimeSampling(), numEmpty); // not hold, then set empties, other set previous if we have previous samples if (!iTimeMap.isHold() || totalSet > 0) { for (index_t emptyIdx = 0; emptyIdx < numEmpty; ++emptyIdx) { if (!iTimeMap.isHold()) { oSchema.set(emptySample); } else { oSchema.setFromPrevious(); } } totalSet += numEmpty; } for (; reqIdx < numSamples; reqIdx++, totalSet++) { IPointsSchema::Sample iSamp = iSchema.getValue(reqIdx); OPointsSchema::Sample oSamp; Abc::P3fArraySamplePtr posPtr = iSamp.getPositions(); if (posPtr) oSamp.setPositions(*posPtr); Abc::UInt64ArraySamplePtr idPtr = iSamp.getIds(); if (idPtr) oSamp.setIds(*idPtr); Abc::V3fArraySamplePtr velocPtr = iSamp.getVelocities(); if (velocPtr) oSamp.setVelocities(*velocPtr); IFloatGeomParam::Sample iWidthSample; OFloatGeomParam::Sample oWidthSample; if (iWidths) { getOGeomParamSamp (iWidths, iWidthSample, oWidthSample, reqIdx); oSamp.setWidths(oWidthSample); } oSchema.set(oSamp); // our first sample was written, AND we want to hold so set our previous samples to this one! if (iTimeMap.isHold() && totalSet == 0) { for (index_t emptyIdx = 0; emptyIdx < numEmpty; ++emptyIdx) { oSchema.setFromPrevious(); } totalSet += numEmpty; } } } for (size_t i = totalSet; i < totalSamples; ++i) { if (!iTimeMap.isHold()) { oSchema.set(emptySample); } else { oSchema.setFromPrevious(); } } } else if (INuPatch::matches(header)) { ONuPatchSchema oSchema; init< INuPatch, INuPatchSchema, ONuPatch, ONuPatchSchema >( iObjects, oParentObj, oSchema, iTimeMap, totalSamples); outObj = oSchema.getObject(); Alembic::Util::int32_t zeroVal = 0; ONuPatchSchema::Sample emptySample(P3fArraySample::emptySample(), zeroVal, zeroVal, zeroVal, zeroVal, FloatArraySample::emptySample(), FloatArraySample::emptySample()); // stitch the NuPatchSchemas // for (size_t i = 0; i < iObjects.size(); i++) { if (!iObjects[i].valid()) { continue; } INuPatchSchema iSchema = INuPatch(iObjects[i]).getSchema(); index_t numSamples = iSchema.getNumSamples(); IN3fGeomParam normals = iSchema.getNormalsParam(); IV2fGeomParam uvs = iSchema.getUVsParam(); index_t numEmpty = 0; index_t reqIdx = getIndexSample(totalSet, oSchema.getTimeSampling(), numSamples, iSchema.getTimeSampling(), numEmpty); // not hold, then set empties, other set previous if we have previous samples if (!iTimeMap.isHold() || totalSet > 0) { for (index_t emptyIdx = 0; emptyIdx < numEmpty; ++emptyIdx) { if (!iTimeMap.isHold()) { oSchema.set(emptySample); } else { oSchema.setFromPrevious(); } } totalSet += numEmpty; } for (; reqIdx < numSamples; reqIdx++, totalSet++) { INuPatchSchema::Sample iSamp = iSchema.getValue(reqIdx); ONuPatchSchema::Sample oSamp; Abc::P3fArraySamplePtr posPtr = iSamp.getPositions(); if (posPtr) oSamp.setPositions(*posPtr); Abc::V3fArraySamplePtr velocPtr = iSamp.getVelocities(); if (velocPtr) oSamp.setVelocities(*velocPtr); oSamp.setNu(iSamp.getNumU()); oSamp.setNv(iSamp.getNumV()); oSamp.setUOrder(iSamp.getUOrder()); oSamp.setVOrder(iSamp.getVOrder()); Abc::FloatArraySamplePtr uKnotsPtr = iSamp.getUKnot(); if (uKnotsPtr) oSamp.setUKnot(*uKnotsPtr); Abc::FloatArraySamplePtr vKnotsPtr = iSamp.getVKnot(); if (vKnotsPtr) oSamp.setVKnot(*vKnotsPtr); IV2fGeomParam::Sample iUVSample; OV2fGeomParam::Sample oUVSample; if (uvs) { getOGeomParamSamp (uvs, iUVSample, oUVSample, reqIdx); oSamp.setUVs(oUVSample); } IN3fGeomParam::Sample iNormalsSample; ON3fGeomParam::Sample oNormalsSample; if (normals) { getOGeomParamSamp (normals, iNormalsSample, oNormalsSample, reqIdx); oSamp.setNormals(oNormalsSample); } if (iSchema.hasTrimCurve()) { oSamp.setTrimCurve(iSamp.getTrimNumLoops(), *(iSamp.getTrimNumCurves()), *(iSamp.getTrimNumVertices()), *(iSamp.getTrimOrders()), *(iSamp.getTrimKnots()), *(iSamp.getTrimMins()), *(iSamp.getTrimMaxes()), *(iSamp.getTrimU()), *(iSamp.getTrimV()), *(iSamp.getTrimW())); } oSchema.set(oSamp); // our first sample was written, AND we want to hold so set our previous samples to this one! if (iTimeMap.isHold() && totalSet == 0) { for (index_t emptyIdx = 0; emptyIdx < numEmpty; ++emptyIdx) { oSchema.setFromPrevious(); } totalSet += numEmpty; } } } for (size_t i = totalSet; i < totalSamples; ++i) { if (!iTimeMap.isHold()) { oSchema.set(emptySample); } else { oSchema.setFromPrevious(); } } } else { if (!atRoot) { outObj = OObject(oParentObj, header.getName(), header.getMetaData()); } else { // for stitching properties of the top level objects outObj = oParentObj; } // collect the top level compound property ICompoundPropertyVec iCompoundProps(iObjects.size()); for (size_t i = 0; i < iObjects.size(); ++i) { if (!iObjects[i].valid()) { continue; } iCompoundProps[i] = iObjects[i].getProperties(); } OCompoundProperty oCompoundProperty = outObj.getProperties(); stitchCompoundProp(iCompoundProps, oCompoundProperty, iTimeMap); } // After done writing THIS OObject node, if input nodes have children, // go deeper, otherwise we are done here for (size_t i = 0 ; i < iObjects.size(); i++ ) { if (!iObjects[i].valid()) { continue; } for (size_t j = 0; j < iObjects[i].getNumChildren(); ++j) { std::vector< IObject > childObjects; std::string childName = iObjects[i].getChildHeader(j).getName(); // skip names that we've already written out if (outObj.getChildHeader(childName) != NULL) { continue; } for (size_t k =i; k < iObjects.size(); ++k) { childObjects.push_back(iObjects[k].getChild(childName)); } visitObjects(childObjects, outObj, iTimeMap, false); } } } //-***************************************************************************** //-***************************************************************************** // DO IT. //-***************************************************************************** //-***************************************************************************** int main( int argc, char *argv[] ) { if (argc < 4) { std::cerr << "USAGE: " << argv[0] << " [-v] [-hold] outFile.abc inFile1.abc" << " inFile2.abc (inFile3.abc ...)" << std::endl; std::cerr << "Where -v is a verbosity flag which prints the IObject" << " being processed." << std::endl; std::cerr << "And -hold flags whether to fill in the first or previous " << "sample instead of an empty one for missing samples." << std::endl; return -1; } { size_t numInputs = argc - 2; std::string fileName; TimeAndSamplesMap timeMap; std::vector< chrono_t > minVec; minVec.reserve(numInputs); std::vector< IArchive > iArchives; iArchives.reserve(numInputs); std::map< chrono_t, size_t > minIndexMap; Alembic::AbcCoreFactory::IFactory factory; factory.setPolicy(ErrorHandler::kThrowPolicy); Alembic::AbcCoreFactory::IFactory::CoreType coreType; for (int i = 1; i < argc; ++i) { // check for optional verbose if (argv[i] == std::string("-v")) { timeMap.setVerbose(true); numInputs --; continue; } // check for optional hold else if (argv[i] == std::string("-hold")) { timeMap.setHold(true); numInputs --; continue; } // first non flag argument is our output file name else if (fileName.empty()) { fileName = argv[i]; continue; } IArchive archive = factory.getArchive(argv[i], coreType); if (!archive.valid()) { std::cerr << "ERROR: " << argv[i] << " not a valid Alembic file" << std::endl; return 1; } // reorder the input files according to their mins chrono_t min = DBL_MAX; Alembic::Util::uint32_t numSamplings = archive.getNumTimeSamplings(); timeMap.add(archive.getTimeSampling(0), archive.getMaxNumSamplesForTimeSamplingIndex(0)); if (numSamplings > 1) { // timesampling index 0 is special, so it will be skipped // use the first time on the next time sampling to determine // our archive order the archive order min = archive.getTimeSampling(1)->getSampleTime(0); for (Alembic::Util::uint32_t s = 1; s < numSamplings; ++s) { timeMap.add(archive.getTimeSampling(s), archive.getMaxNumSamplesForTimeSamplingIndex(s)); } minVec.push_back(min); if (minIndexMap.count(min) == 0) { minIndexMap.insert(std::make_pair(min, minVec.size() - 1)); } else if (!iArchives.empty()) { std::cerr << "ERROR: overlapping frame range between " << iArchives[0].getName() << " and " << argv[i] << std::endl; return 1; } } iArchives.push_back(archive); } // now reorder the input nodes so they are in increasing order of their // min values in the frame range std::sort(minVec.begin(), minVec.end()); std::vector< IArchive > iOrderedArchives; iOrderedArchives.reserve(numInputs); for (size_t f = 0; f < numInputs; ++f) { size_t index = minIndexMap.find(minVec[f])->second; iOrderedArchives.push_back(iArchives[index]); } // since important meta data hints can be on the archive // and will likely be part of every input in the sequence // propagate the one from the first archive to our output MetaData md = iOrderedArchives[0].getTop().getMetaData(); std::string appWriter = "AbcStitcher"; std::string userStr = md.get(Abc::kUserDescriptionKey); if (!userStr.empty()) { userStr = "AbcStitcher: " + userStr; } // Create an archive with the default writer OArchive oArchive; if (coreType == Alembic::AbcCoreFactory::IFactory::kOgawa) { oArchive = CreateArchiveWithInfo( Alembic::AbcCoreOgawa::WriteArchive(), fileName, appWriter, userStr, md, ErrorHandler::kThrowPolicy); } #ifdef ALEMBIC_WITH_HDF5 else if (coreType == Alembic::AbcCoreFactory::IFactory::kHDF5) { oArchive = CreateArchiveWithInfo( Alembic::AbcCoreHDF5::WriteArchive(), fileName, appWriter, userStr, md, ErrorHandler::kThrowPolicy); } #endif OObject oRoot = oArchive.getTop(); if (!oRoot.valid()) { return -1; } std::vector iRoots(numInputs); for (size_t e = 0; e < numInputs; ++e) { iRoots[e] = iOrderedArchives[e].getTop(); } visitObjects(iRoots, oRoot, timeMap, true); } return 0; } alembic-1.8.9/bin/AbcStitcher/CMakeLists.txt000066400000000000000000000041351507001531700206320ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** ADD_EXECUTABLE(abcstitcher AbcStitcher.cpp util.cpp) TARGET_LINK_LIBRARIES(abcstitcher Alembic::Alembic) set_target_properties(abcstitcher PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) INSTALL(TARGETS abcstitcher DESTINATION bin) alembic-1.8.9/bin/AbcStitcher/util.cpp000066400000000000000000000511461507001531700175570ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2014, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include "util.h" #include using namespace Alembic::AbcGeom; using namespace Alembic::Abc; using namespace Alembic::AbcCoreAbstract; void TimeAndSamplesMap::add(TimeSamplingPtr iTime, size_t iNumSamples) { if (iNumSamples == 0) { iNumSamples = 1; } for (size_t i = 0; i < mTimeSampling.size(); ++i) { if (mTimeSampling[i]->getTimeSamplingType() == iTime->getTimeSamplingType()) { chrono_t curLastTime = mTimeSampling[i]->getSampleTime(mExpectedSamples[i]); chrono_t lastTime = iTime->getSampleTime(iNumSamples); if (lastTime < curLastTime) { lastTime = curLastTime; } if (mTimeSampling[i]->getSampleTime(0) > iTime->getSampleTime(0)) { mTimeSampling[i] = iTime; } mExpectedSamples[i] = mTimeSampling[i]->getNearIndex(lastTime, std::numeric_limits< index_t >::max()).first; return; } } mTimeSampling.push_back(iTime); mExpectedSamples.push_back(iNumSamples); } TimeSamplingPtr TimeAndSamplesMap::get(TimeSamplingPtr iTime, std::size_t & oNumSamples) const { for (size_t i = 0; i < mTimeSampling.size(); ++i) { if (mTimeSampling[i]->getTimeSamplingType() == iTime->getTimeSamplingType()) { oNumSamples = mExpectedSamples[i]; return mTimeSampling[i]; } } oNumSamples = 0; return TimeSamplingPtr(); } index_t getIndexSample(index_t iCurOutIndex, TimeSamplingPtr iOutTime, index_t iInNumSamples, TimeSamplingPtr iInTime, index_t & oNumEmpty) { // see if we are missing any samples for oNumEmpty chrono_t curTime = iOutTime->getSampleTime(iCurOutIndex); chrono_t inChrono = iInTime->getSampleTime(0); if (curTime < inChrono) { index_t emptyEnd = iOutTime->getNearIndex(inChrono, std::numeric_limits::max()).first; if (emptyEnd > iCurOutIndex) { oNumEmpty = emptyEnd - iCurOutIndex; } else { oNumEmpty = 0; } } else { oNumEmpty = 0; } for (index_t i = 0; i < iInNumSamples; ++i) { inChrono = iInTime->getSampleTime(i); if (curTime <= inChrono || Imath::equalWithAbsError(curTime, inChrono, 1e-5)) { return i; } } return iInNumSamples; } void checkAcyclic(const TimeSamplingType & tsType, const std::string & fullNodeName) { if (tsType.isAcyclic()) { std::cerr << "No support for stitching acyclic sampling node " << fullNodeName << std::endl; exit(1); } } void stitchArrayProp(const PropertyHeader & propHeader, const ICompoundPropertyVec & iCompoundProps, OCompoundProperty & oCompoundProp, const TimeAndSamplesMap & iTimeMap) { size_t totalSamples = 0; TimeSamplingPtr timePtr = iTimeMap.get(propHeader.getTimeSampling(), totalSamples); const DataType & dataType = propHeader.getDataType(); const MetaData & metaData = propHeader.getMetaData(); const std::string & propName = propHeader.getName(); Dimensions emptyDims(0); ArraySample emptySample(NULL, dataType, emptyDims); OArrayProperty writer(oCompoundProp, propName, dataType, metaData, timePtr); size_t numInputs = iCompoundProps.size(); for (size_t iCpIndex = 0; iCpIndex < numInputs; iCpIndex++) { if (!iCompoundProps[iCpIndex].valid()) { continue; } const PropertyHeader * childHeader = iCompoundProps[iCpIndex].getPropertyHeader(propName); if (!childHeader || dataType != childHeader->getDataType()) { continue; } IArrayProperty reader(iCompoundProps[iCpIndex], propName); index_t numSamples = reader.getNumSamples(); ArraySamplePtr dataPtr; index_t numEmpty; index_t k = getIndexSample(writer.getNumSamples(), writer.getTimeSampling(), numSamples, reader.getTimeSampling(), numEmpty); for (index_t j = 0; j < numEmpty; ++j) { if (!iTimeMap.isHold()) { writer.set(emptySample); } else if (writer.getNumSamples() == 0) { reader.get(dataPtr, 0); writer.set(*dataPtr); } else { writer.setFromPrevious(); } } for (; k < numSamples; k++) { reader.get(dataPtr, k); writer.set(*dataPtr); } } // fill in any other empties for (size_t i = writer.getNumSamples(); i < totalSamples; ++i) { if (!iTimeMap.isHold()) { writer.set(emptySample); } else { writer.setFromPrevious(); } } } // return true if we needed to stitch the geom param bool stitchArbGeomParam(const PropertyHeader & propHeader, const ICompoundPropertyVec & iCompoundProps, OCompoundProperty & oCompoundProp, const TimeAndSamplesMap & iTimeMap) { // go through all the inputs to see if all the property types are the same size_t numInputs = iCompoundProps.size(); const std::string & propName = propHeader.getName(); PropertyType ptype = propHeader.getPropertyType(); bool diffProp = false; for (size_t iCpIndex = 1; iCpIndex < numInputs && diffProp == false; iCpIndex++) { if (!iCompoundProps[iCpIndex].valid()) { continue; } const PropertyHeader * childHeader = iCompoundProps[iCpIndex].getPropertyHeader(propName); if (childHeader && childHeader->getPropertyType() != ptype) { diffProp = true; } } // all of the props are the same, lets stitch them like normal if (!diffProp) { return false; } // we have a mismatch of indexed and non-index geom params, lets stitch them // together AS indexed std::vector< IArrayProperty > valsProp(numInputs); std::vector< IArrayProperty > indicesProp(numInputs); bool firstVals = true; DataType dataType; MetaData metaData; TimeSamplingPtr timePtr; // first we need to get our attrs for (size_t iCpIndex = 0; iCpIndex < numInputs; iCpIndex++) { if (!iCompoundProps[iCpIndex].valid()) { continue; } const PropertyHeader * childHeader = iCompoundProps[iCpIndex].getPropertyHeader(propName); if (childHeader && childHeader->isArray()) { valsProp[iCpIndex] = IArrayProperty(iCompoundProps[iCpIndex], propName); if (firstVals) { firstVals = false; dataType = valsProp[iCpIndex].getDataType(); metaData = valsProp[iCpIndex].getMetaData(); timePtr = valsProp[iCpIndex].getTimeSampling(); } } else if (childHeader && childHeader->isCompound()) { ICompoundProperty cprop(iCompoundProps[iCpIndex], propName); if (cprop.getPropertyHeader(".vals") != NULL && cprop.getPropertyHeader(".indices") != NULL) { valsProp[iCpIndex] = IArrayProperty(cprop, ".vals"); indicesProp[iCpIndex] = IArrayProperty(cprop, ".indices"); if (firstVals) { firstVals = false; dataType = valsProp[iCpIndex].getDataType(); metaData = valsProp[iCpIndex].getMetaData(); timePtr = valsProp[iCpIndex].getTimeSampling(); } } } } size_t totalSamples = 0; timePtr = iTimeMap.get(timePtr, totalSamples); DataType indicesType(Alembic::Util::kUint32POD); Dimensions emptyDims(0); ArraySample emptySample(NULL, dataType, emptyDims); ArraySample emptyIndicesSample(NULL, indicesType, emptyDims); // we write indices and vals together OCompoundProperty ocProp(oCompoundProp, propName, metaData); OArrayProperty valsWriter(ocProp, ".vals", dataType, metaData, timePtr); OArrayProperty indicesWriter(ocProp, ".indices", indicesType, timePtr); for (size_t index = 0; index < numInputs; index++) { if (!valsProp[index].valid()) { continue; } index_t numSamples = valsProp[index].getNumSamples(); ArraySamplePtr dataPtr; index_t numEmpty; index_t k = getIndexSample(valsWriter.getNumSamples(), valsWriter.getTimeSampling(), numSamples, valsProp[index].getTimeSampling(), numEmpty); for (index_t j = 0; j < numEmpty; ++j) { if (!iTimeMap.isHold()) { valsWriter.set(emptySample); indicesWriter.set(emptyIndicesSample); } else if (valsWriter.getNumSamples() == 0) { valsProp[index].get(dataPtr, 0); valsWriter.set(*dataPtr); // if (indicesProp[index].valid()) { indicesProp[index].get(dataPtr, 0); indicesWriter.set(*dataPtr); } } else { valsWriter.setFromPrevious(); indicesWriter.setFromPrevious(); } } for (; k < numSamples; k++) { valsProp[index].get(dataPtr, k); valsWriter.set(*dataPtr); if (indicesProp[index].valid()) { indicesProp[index].get(dataPtr, k); indicesWriter.set(*dataPtr); } else { // we need to construct our indices manually Dimensions dataDims = dataPtr->getDimensions(); std::vector indicesVec( dataDims.numPoints()); for (size_t dataIdx = 0; dataIdx < indicesVec.size(); ++dataIdx) { indicesVec[dataIdx] = (Alembic::Util::uint32_t) dataIdx; } // set the empty sample if (indicesVec.empty()) { indicesWriter.set(emptyIndicesSample); } else { ArraySample indicesSamp(&indicesVec.front(), indicesType, dataDims); indicesWriter.set(indicesSamp); } } } } // fill in any other empties for (size_t i = valsWriter.getNumSamples(); i < totalSamples; ++i) { if (!iTimeMap.isHold()) { valsWriter.set(emptySample); indicesWriter.set(emptyIndicesSample); } else { valsWriter.setFromPrevious(); indicesWriter.setFromPrevious(); } } return true; } template< typename T > void scalarPropIO(IScalarProperty & reader, Alembic::Util::uint8_t extent, OScalarProperty & writer, bool hold) { std::vector< T > data(extent); std::vector< T > emptyData(extent); void * emptyPtr = static_cast< void* >(&emptyData.front()); void * vPtr = static_cast< void* >(&data.front()); index_t numSamples = reader.getNumSamples(); index_t numEmpty; index_t k = getIndexSample(writer.getNumSamples(), writer.getTimeSampling(), numSamples, reader.getTimeSampling(), numEmpty); // not really empty, but set to a default 0 or empty string value for (index_t i = 0; i < numEmpty; ++i) { if (!hold) { writer.set(emptyPtr); } else if (writer.getNumSamples() == 0) { reader.get(vPtr, 0); writer.set(vPtr); } else { writer.setFromPrevious(); } } for (; k < numSamples; ++k) { reader.get(vPtr, k); writer.set(vPtr); } } void stitchScalarProp(const PropertyHeader & propHeader, const ICompoundPropertyVec & iCompoundProps, OCompoundProperty & oCompoundProp, const TimeAndSamplesMap & iTimeMap) { size_t totalSamples = 0; TimeSamplingPtr timePtr = iTimeMap.get(propHeader.getTimeSampling(), totalSamples); const DataType & dataType = propHeader.getDataType(); const MetaData & metaData = propHeader.getMetaData(); const std::string & propName = propHeader.getName(); Alembic::Util::PlainOldDataType pod = dataType.getPod(); OScalarProperty writer(oCompoundProp, propName, dataType, metaData, timePtr); size_t numInputs = iCompoundProps.size(); for (size_t iCpIndex = 0; iCpIndex < numInputs; iCpIndex++) { if (!iCompoundProps[iCpIndex].valid()) { continue; } const PropertyHeader * childHeader = iCompoundProps[iCpIndex].getPropertyHeader(propName); if (!childHeader || dataType != childHeader->getDataType()) { continue; } IScalarProperty reader(iCompoundProps[iCpIndex], propName); Alembic::Util::uint8_t extent = dataType.getExtent(); switch(pod) { case Alembic::Util::kBooleanPOD: scalarPropIO< Alembic::Util::bool_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kUint8POD: scalarPropIO< Alembic::Util::uint8_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kInt8POD: scalarPropIO< Alembic::Util::int8_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kUint16POD: scalarPropIO< Alembic::Util::uint16_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kInt16POD: scalarPropIO< Alembic::Util::int16_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kUint32POD: scalarPropIO< Alembic::Util::uint32_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kInt32POD: scalarPropIO< Alembic::Util::int32_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kUint64POD: scalarPropIO< Alembic::Util::uint64_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kInt64POD: scalarPropIO< Alembic::Util::int64_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kFloat16POD: scalarPropIO< Alembic::Util::float16_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kFloat32POD: scalarPropIO< Alembic::Util::float32_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kFloat64POD: scalarPropIO< Alembic::Util::float64_t >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kStringPOD: scalarPropIO< Alembic::Util::string >(reader, extent, writer, iTimeMap.isHold()); break; case Alembic::Util::kWstringPOD: scalarPropIO< Alembic::Util::wstring >(reader, extent, writer, iTimeMap.isHold()); break; default: break; } } // set any extra empties, or hold std::vector< Alembic::Util::string > emptyStr(dataType.getExtent()); std::vector< Alembic::Util::wstring > emptyWstr(dataType.getExtent()); std::vector< Alembic::Util::uint8_t > emptyBuffer(dataType.getNumBytes()); for (size_t i = writer.getNumSamples(); i < totalSamples; ++i) { if (iTimeMap.isHold()) { writer.setFromPrevious(); } else if (pod == Alembic::Util::kStringPOD) { writer.set(&emptyStr.front()); } else if (pod == Alembic::Util::kWstringPOD) { writer.set(&emptyWstr.front()); } else { writer.set(&emptyBuffer.front()); } } } void stitchCompoundProp(ICompoundPropertyVec & iCompoundProps, OCompoundProperty & oCompoundProp, const TimeAndSamplesMap & iTimeMap) { size_t numCompounds = iCompoundProps.size(); for (size_t i = 0; i < numCompounds; ++i) { if (!iCompoundProps[i].valid()) { continue; } size_t numProps = iCompoundProps[i].getNumProperties(); for (size_t propIndex = 0; propIndex < numProps; propIndex++) { const PropertyHeader & propHeader = iCompoundProps[i].getPropertyHeader(propIndex); if (oCompoundProp.getPropertyHeader(propHeader.getName()) != NULL) { continue; } if (propHeader.getMetaData().get("isGeomParam") == "true" && stitchArbGeomParam(propHeader, iCompoundProps, oCompoundProp, iTimeMap)) { continue; } else if (propHeader.isCompound()) { ICompoundPropertyVec childProps; for (size_t j = i; j < numCompounds; ++j) { if (!iCompoundProps[j].valid() || iCompoundProps[j].getPropertyHeader( propHeader.getName()) == NULL) { continue; } childProps.push_back(ICompoundProperty(iCompoundProps[j], propHeader.getName())); } OCompoundProperty child(oCompoundProp, propHeader.getName(), propHeader.getMetaData()); stitchCompoundProp(childProps, child, iTimeMap); } else if (propHeader.isScalar()) { stitchScalarProp(propHeader, iCompoundProps, oCompoundProp, iTimeMap); } else if (propHeader.isArray()) { stitchArrayProp(propHeader, iCompoundProps, oCompoundProp, iTimeMap); } } } } alembic-1.8.9/bin/AbcStitcher/util.h000066400000000000000000000100301507001531700172070ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef ABC_STITCHER_UTIL_H #define ABC_STITCHER_UTIL_H #include #include #include #include typedef std::vector< Alembic::Abc::ICompoundProperty > ICompoundPropertyVec; class TimeAndSamplesMap { public: TimeAndSamplesMap() {m_isVerbose = false; m_hold = false;}; void add(Alembic::AbcCoreAbstract::TimeSamplingPtr iTime, std::size_t iNumSamples); Alembic::AbcCoreAbstract::TimeSamplingPtr get( Alembic::AbcCoreAbstract::TimeSamplingPtr iTime, std::size_t & oNumSamples) const; void setVerbose(bool isVerbose){m_isVerbose = isVerbose;}; bool isVerbose() const {return m_isVerbose;}; void setHold(bool isHold){m_hold = isHold;}; bool isHold() const {return m_hold;}; private: std::vector< Alembic::AbcCoreAbstract::TimeSamplingPtr > mTimeSampling; std::vector< std::size_t > mExpectedSamples; bool m_isVerbose; bool m_hold; }; Alembic::AbcCoreAbstract::index_t getIndexSample(Alembic::AbcCoreAbstract::index_t iCurOutIndex, Alembic::AbcCoreAbstract::TimeSamplingPtr iOutTime, Alembic::AbcCoreAbstract::index_t iInNumSamples, Alembic::AbcCoreAbstract::TimeSamplingPtr iInTime, Alembic::AbcCoreAbstract::index_t & oNumEmpty); void checkAcyclic(const Alembic::AbcCoreAbstract::TimeSamplingType & tsType, const std::string & fullNodeName); void stitchArrayProp(const Alembic::AbcCoreAbstract::PropertyHeader & propHeader, const ICompoundPropertyVec & iCompoundProps, Alembic::Abc::OCompoundProperty & oCompoundProp, const TimeAndSamplesMap & iTimeMap); void stitchScalarProp(const Alembic::AbcCoreAbstract::PropertyHeader & propHeader, const ICompoundPropertyVec & iCompoundProps, Alembic::Abc::OCompoundProperty & oCompoundProp, const TimeAndSamplesMap & iTimeMap); void stitchCompoundProp(ICompoundPropertyVec & iCompoundProps, Alembic::Abc::OCompoundProperty & oCompoundProp, const TimeAndSamplesMap & iTimeMap); #endif // ABC_STITCHER_UTIL_H alembic-1.8.9/bin/AbcTree/000077500000000000000000000000001507001531700152015ustar00rootroot00000000000000alembic-1.8.9/bin/AbcTree/AbcTree.cpp000066400000000000000000000340431507001531700172160ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif #include #include #include #include #include #include #include #include #include #ifdef _MSC_VER // set up _S_ISDIR() #if !defined(S_ISDIR) # if defined( _S_IFDIR) && !defined( __S_IFDIR) # define __S_IFDIR _S_IFDIR # endif # define S_ISDIR(mode) (mode&__S_IFDIR) #endif #endif // _MSC_VER namespace Abc = ::Alembic::Abc;; namespace AbcA = ::Alembic::AbcCoreAbstract; namespace AbcF = ::Alembic::AbcCoreFactory; namespace AbcG = ::Alembic::AbcGeom; #define RESETCOLOR "\033[0m" #define GREENCOLOR "\033[1;32m" #define BLUECOLOR "\033[1;34m" #define BOLD "\033[1m" //-***************************************************************************** bool is_leaf( AbcG::IObject iObj ) { if ( !iObj.getParent().valid() ) { return true; } Abc::IObject parent = iObj.getParent(); int numChildren = parent.getNumChildren(); Abc::IObject test = parent.getChild(numChildren - 1); if ( test.valid() && test.getName() != iObj.getName() ) { return false; } return true; } //-***************************************************************************** bool is_leaf( Abc::ICompoundProperty iProp, Abc::PropertyHeader iHeader ) { if ( !iProp.valid() ) { return true; } int last = iProp.getNumProperties() - 1; Abc::PropertyHeader header = iProp.getPropertyHeader( last ); if ( header.getName() == iHeader.getName() ) return true; return false; } //-***************************************************************************** int index( Abc::ICompoundProperty iProp, Abc::PropertyHeader iHeader ) { for ( size_t i = 0 ; i < iProp.getNumProperties() ; i++ ) { Abc::PropertyHeader header = iProp.getPropertyHeader( i ); if ( header.getName() == iHeader.getName() ) { return i; } } return -1; } //-***************************************************************************** void tree( Abc::IScalarProperty iProp, std::string prefix = "" ) { if ( iProp.getObject().getFullName() != "/" ) { prefix = prefix + " "; } if ( is_leaf( iProp.getParent(), iProp.getHeader() ) && ( iProp.getObject().getNumChildren() == 0 || iProp.getParent().getName() != "" ) ) { std::cout << prefix << " `--"; } else { std::cout << prefix << " :--"; prefix = prefix + " :"; } std::cout << iProp.getName() << "\r" << std::endl; } //-***************************************************************************** void tree( Abc::IArrayProperty iProp, std::string prefix = "" ) { if ( iProp.getObject().getFullName() != "/" ) { prefix = prefix + " "; } if ( is_leaf( iProp.getParent(), iProp.getHeader() ) && ( iProp.getObject().getNumChildren() == 0 || iProp.getParent().getName() != "" ) ) { std::cout << prefix << " `--"; } else { std::cout << prefix << " :--"; prefix = prefix + " :"; } std::cout << iProp.getName() << "\r" << std::endl; } //-***************************************************************************** void tree( Abc::ICompoundProperty iProp, std::string prefix = "" ) { if ( iProp.getObject().getFullName() != "/" ) { prefix = prefix + " "; } if ( is_leaf( iProp.getParent(), iProp.getHeader() ) && iProp.getObject().getNumChildren() == 0 ) { std::cout << prefix << " `--"; prefix = prefix + " "; } else { if ( is_leaf( iProp.getParent(), iProp.getHeader() ) ) { std::cout << prefix << " | `--"; prefix = prefix + " |"; } else if ( iProp.getObject().getNumChildren() == 0 ) { std::cout << prefix << " :--"; prefix = prefix + " :"; } else if ( is_leaf( iProp, iProp.getHeader() ) ) { std::cout << prefix << " | `--"; prefix = prefix + " |"; } else { std::cout << prefix << " | :--"; prefix = prefix + " | :"; } } std::cout << iProp.getName() << "\r" << std::endl; for ( size_t i = 0 ; i < iProp.getNumProperties() ; i++ ) { Abc::PropertyHeader header = iProp.getPropertyHeader( i ); if ( header.isScalar() ) { tree( Abc::IScalarProperty( iProp, header.getName() ), prefix ); } else if ( header.isArray() ) { tree( Abc::IArrayProperty( iProp, header.getName() ), prefix ); } else { tree( Abc::ICompoundProperty( iProp, header.getName() ), prefix ); } } } //-***************************************************************************** void tree( AbcG::IObject iObj, bool showProps = false, std::string prefix = "" ) { std::string path = iObj.getFullName(); if ( path == "/" ) { prefix = ""; } else { if ( iObj.getParent().getFullName() != "/" ) { prefix = prefix + " "; } if ( is_leaf( iObj ) ) { std::cout << prefix << " `--"; prefix = prefix + " "; } else { std::cout << prefix << " |--"; prefix = prefix + " |"; } }; if ( showProps ) std::cout << GREENCOLOR; std::cout << iObj.getName(); if ( showProps ) std::cout << RESETCOLOR; std::cout << "\r" << std::endl; // property tree if ( showProps ) { Abc::ICompoundProperty props = iObj.getProperties(); for ( size_t i = 0 ; i < props.getNumProperties() ; i++ ) { Abc::PropertyHeader header = props.getPropertyHeader( i ); if ( header.isScalar() ) { tree( Abc::IScalarProperty( props, header.getName() ), prefix ); } else if ( header.isArray() ) { tree( Abc::IArrayProperty( props, header.getName() ), prefix ); } else { tree( Abc::ICompoundProperty( props, header.getName() ), prefix ); } } } // object tree for ( size_t i = 0 ; i < iObj.getNumChildren() ; i++ ) { tree( AbcG::IObject( iObj, iObj.getChildHeader(i).getName() ), showProps, prefix ); }; } //-***************************************************************************** bool isFile( const std::string& filename ) { struct stat buf; if ( stat(filename.c_str(), &buf) == 0 && !S_ISDIR( buf.st_mode ) ) { return true; } return false; } //-***************************************************************************** bool optionExists(std::vector options, std::string option) { for ( std::size_t i = 0; i < options.size(); i++ ) if ( options[i].find(option) != std::string::npos ) return true; return false; } //-***************************************************************************** int main( int argc, char *argv[] ) { bool opt_all = false; bool opt_meta = false; std::string desc( "abctree [OPTION] FILE[/NAME]\n" " -a include properties listings\n" " -h, --help prints this help message\n" " -m print metadata\n" ); // check for min args if ( argc < 2 ) { std::cout << desc << std::endl; return 0; }; // parse args std::vector arguments(argv, argv + argc); std::vector options; std::vector files; // separate file args from option args for ( std::size_t i = 1; i < arguments.size(); i++ ) { if ( arguments[ i ].substr( 0, 1 ) == "-" ) options.push_back( arguments[ i ] ); else files.push_back( arguments[ i ] ); } // help if ( argc < 2 || optionExists( options, "h" ) || optionExists( options, "help" ) ) { std::cout << desc << std::endl; return 0; }; // set some flags opt_all = optionExists( options, "a"); opt_meta = optionExists( options, "m"); // open each file for ( std::size_t i = 0; i < files.size(); i++ ) { if ( files.size() > 1 ) std::cout << BOLD << files[i] << ':' << RESETCOLOR << std::endl; std::stringstream ss( files[i] ); std::stringstream fp; std::string segment; std::vector seglist; /* * separate file and object paths, e.g. * * ../dir1/foo.abc/bar/baz * \_____________/\______/ * file obj */ int j = 0; while ( std::getline( ss, segment, '/' ) ) { if ( !isFile ( fp.str() ) ) { if ( j != 0 ) fp << "/"; fp << segment; } else { seglist.push_back( segment ); } ++j; } // open the iarchive Abc::IArchive archive; AbcF::IFactory factory; factory.setPolicy(Abc::ErrorHandler::kQuietNoopPolicy); AbcF::IFactory::CoreType coreType; archive = factory.getArchive(std::string( fp.str() ), coreType); // display file metadata if ( opt_meta ) { std::cout << "Using " << Alembic::AbcCoreAbstract::GetLibraryVersion () << std::endl;; std::string appName; std::string libraryVersionString; Alembic::Util::uint32_t libraryVersion; std::string whenWritten; std::string userDescription; std::string coreName; GetArchiveInfo (archive, appName, libraryVersionString, libraryVersion, whenWritten, userDescription); if ( coreType == AbcF::IFactory::kOgawa ) { coreName = "Ogawa"; } else if ( coreType == AbcF::IFactory::kHDF5 ) { coreName = "HDF5"; } else { coreName = "Unknown"; }; if ( appName != "" ) { std::cout << " file written by: " << appName << std::endl; std::cout << " using Alembic : " << libraryVersionString << std::endl; std::cout << " written on : " << whenWritten << std::endl; std::cout << " user description : " << userDescription << std::endl; } else { std::cout << " (file doesn't have any ArchiveInfo)" << std::endl; } std::cout << " core type : " << coreName << std::endl; }; // walk object hierarchy and find valid objects AbcG::IObject test = archive.getTop(); AbcG::IObject iObj = test; while ( test.valid() && seglist.size() > 0 ) { test = test.getChild( seglist.front() ); if ( test.valid() ) { iObj = test; seglist.erase( seglist.begin() ); } } // walk property hierarchy for most recent valid object Abc::ICompoundProperty props = iObj.getProperties(); const Abc::PropertyHeader* header; bool found = false; for ( std::size_t i = 0; i < seglist.size(); ++i ) { header = props.getPropertyHeader( seglist[i] ); if ( header && header->isCompound() ) { Abc::ICompoundProperty ptest( props, header->getName() ); if ( ptest.valid() ) { props = ptest; found = true; } } else if ( header && header->isSimple() ) { found = true; } else { std::cout << seglist[i] << ": Invalid object or property" << std::endl; return 1; } } // walk the archive tree if ( found ) if ( header->isCompound() ) tree( props ); else tree( Abc::IScalarProperty( props, header->getName() ) ); else tree( iObj, opt_all ); } return 0; } alembic-1.8.9/bin/AbcTree/CMakeLists.txt000066400000000000000000000041001507001531700177340ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2013-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** ADD_EXECUTABLE(abctree AbcTree.cpp) TARGET_LINK_LIBRARIES(abctree Alembic::Alembic) set_target_properties(abctree PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) INSTALL(TARGETS abctree DESTINATION bin) alembic-1.8.9/bin/AbcWalk/000077500000000000000000000000001507001531700152005ustar00rootroot00000000000000alembic-1.8.9/bin/AbcWalk/Main.cpp000066400000000000000000000232311507001531700165710ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2013, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #include double getTimeSec() { timeval t; gettimeofday(&t, 0); return (double) t.tv_sec + (double) t.tv_usec / 1000000.0; } using namespace Alembic; struct ArchiveAndData { Abc::IArchive archive; std::vector< Abc::IArrayProperty > arrays; std::vector< Abc::IScalarProperty > scalars; std::size_t maxNumSamples; }; class ArchiveWalker; // used two different ways, one when traverse the archives // (int archive is ignored), and one where we read samples struct WorkUnit { int start; int end; int archive; ArchiveWalker * walker; }; class ArchiveWalker { public: std::vector< ArchiveAndData > mArchives; void addArchive(Abc::IArchive iArchive) { ArchiveAndData data; data.archive = iArchive; data.maxNumSamples = 0; mArchives.push_back(data); } void readProps(WorkUnit & data) { size_t numArchives = mArchives.size(); printf("readProps Work Unit Start %d %d\n", data.start, data.end); double startTime = getTimeSec(); for (size_t a = 0; a < numArchives; ++a) { std::size_t numScalars = mArchives[a].scalars.size(); std::size_t numArrays = mArchives[a].arrays.size(); for (std::size_t i = 0; i < numScalars; ++i) { Abc::IScalarProperty & prop = mArchives[a].scalars[i]; int propEnd = std::min(data.end, (int) prop.getNumSamples()); if (prop.isConstant()) { propEnd = 1; } for (int j = data.start; j < propEnd; ++j) { if (prop.getDataType().getPod() != Alembic::Util::kStringPOD) { char buffer[4096]; prop.get(buffer, j); } else { std::vector< std::string > buffer( prop.getDataType().getExtent()); prop.get(&buffer.front(), j); } } } for (std::size_t i = 0; i < numArrays; ++i) { Abc::IArrayProperty & prop = mArchives[a].arrays[i]; int propEnd = std::min(data.end, (int) prop.getNumSamples()); if (prop.isConstant()) { propEnd = 1; } for (int j = data.start; j < propEnd; ++j) { Alembic::AbcCoreAbstract::ArraySamplePtr samp; prop.get(samp, j); } } } printf("readProps Work Unit End %d %d %f\n", data.start, data.end, getTimeSec() - startTime); pthread_exit(0); } void findProps(int iArchiveNum, Abc::ICompoundProperty & iParent) { size_t numProps = iParent.getNumProperties(); for (size_t i = 0; i < numProps; ++i) { const Alembic::AbcCoreAbstract::PropertyHeader & childHeader = iParent.getPropertyHeader(i); if (childHeader.isScalar()) { Alembic::Abc::IScalarProperty prop(iParent, childHeader.getName()); if (prop.getNumSamples() > 0) { mArchives[iArchiveNum].scalars.push_back(prop); mArchives[iArchiveNum].maxNumSamples = std::max( mArchives[iArchiveNum].maxNumSamples, prop.getNumSamples()); } } else if (childHeader.isArray()) { Alembic::Abc::IArrayProperty prop(iParent, childHeader.getName()); if (prop.getNumSamples() > 0) { mArchives[iArchiveNum].arrays.push_back(prop); mArchives[iArchiveNum].maxNumSamples = std::max( mArchives[iArchiveNum].maxNumSamples, prop.getNumSamples()); } } else { Alembic::Abc::ICompoundProperty prop(iParent, childHeader.getName()); findProps(iArchiveNum, prop); } } } void walkObjects(int iArchiveNum, Abc::IObject & iParent) { size_t numChildren = iParent.getNumChildren(); for (size_t i = 0; i < numChildren; i++) { const Abc::ObjectHeader & header = iParent.getChildHeader(i); Abc::IObject child(iParent, header.getName()); Abc::ICompoundProperty prop = child.getProperties(); findProps(iArchiveNum, prop); walkObjects(iArchiveNum, child); } } void walkArchives(WorkUnit & data) { printf("walkArchives Work Unit Start %d %d\n", data.start, data.end); for (int i = data.start; i < data.end; ++i) { Abc::IObject top = mArchives[i].archive.getTop(); walkObjects(i, top); } printf("walkArchives Work Unit End %d %d\n", data.start, data.end); } }; void * readPropsWrap(void * ptr) { WorkUnit * data = (WorkUnit *) ptr; data->walker->readProps(*data); pthread_exit(0); } void * walkArchivesWrap(void * ptr) { WorkUnit * data = (WorkUnit *) ptr; data->walker->walkArchives(*data); pthread_exit(0); } int main(int argc, char ** argv) { if (argc < 4) { printf ("sceneWalk maxNumThreads ogawaStreams fileName [fileName ...]\n"); return 0; } int maxThreads = atoi(argv[1]); int ogawaStreams = atoi(argv[2]); { ArchiveWalker walker; Alembic::AbcCoreFactory::IFactory factory; Alembic::AbcCoreFactory::IFactory::CoreType coreType; factory.setOgawaNumStreams(ogawaStreams); double time_start = getTimeSec(); for (int i = 3; i < argc; ++i) { Abc::IArchive archive = factory.getArchive(argv[i], coreType); if (archive.valid()) { walker.addArchive(archive); } } int numTraverse = std::min(maxThreads, (int) walker.mArchives.size()); std::vector traverseArchives(numTraverse); int lastEnd = 0; int workSize = walker.mArchives.size() / numTraverse; int workRem = 0; if ((int) walker.mArchives.size() > numTraverse) workRem = walker.mArchives.size() % numTraverse; pthread_t * walkThreads = new pthread_t[numTraverse]; for (int i = 0; i < numTraverse; ++i) { traverseArchives[i].archive = i; traverseArchives[i].start = lastEnd; traverseArchives[i].walker = &walker; lastEnd += workSize; if (i < workRem) lastEnd ++; traverseArchives[i].end = lastEnd; pthread_create(&(walkThreads[i]), NULL, walkArchivesWrap, (void *) &(traverseArchives[i])); } for (int i = 0; i < numTraverse; ++i) { pthread_join(walkThreads[i], NULL); } delete [] walkThreads; double totalTime = getTimeSec() - time_start; printf ("Property Collection Wall Time: %f\n\n", totalTime); time_start = getTimeSec(); size_t maxSamples = 0; for (size_t i = 0; i < walker.mArchives.size(); ++i) { maxSamples = std::max(walker.mArchives[i].maxNumSamples, maxSamples); } int numSamples = std::min(maxThreads, (int) maxSamples); std::vector readSamples(numSamples); lastEnd = 0; workSize = maxSamples / numSamples; workRem = 0; if ((int) maxSamples > numSamples) workRem = maxSamples % numSamples; pthread_t * readThreads = new pthread_t[numSamples]; for (int i = 0; i < numSamples; ++i) { readSamples[i].archive = i; // ignored readSamples[i].start = lastEnd; readSamples[i].walker = &walker; lastEnd += workSize; if (i < workRem) lastEnd ++; readSamples[i].end = lastEnd; pthread_create(&(readThreads[i]), NULL, readPropsWrap, (void *) &(readSamples[i])); } for (int i = 0; i < numSamples; ++i) { pthread_join(readThreads[i], NULL); } delete [] readThreads; totalTime = getTimeSec()-time_start; printf ("Property Read Wall Time: %f\n\n", totalTime); } return 0; } alembic-1.8.9/bin/AbcWalk/README000066400000000000000000000002301507001531700160530ustar00rootroot00000000000000This is meant to test reading speed and to compare multi-threaded HDF vs Ogawa reading. It's not multi-platform which is why no CMakefile is provided. alembic-1.8.9/bin/CMakeLists.txt000066400000000000000000000041071507001531700164360ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** ADD_SUBDIRECTORY(AbcEcho) ADD_SUBDIRECTORY(AbcLs) ADD_SUBDIRECTORY(AbcTree) ADD_SUBDIRECTORY(AbcStitcher) ADD_SUBDIRECTORY(AbcDiff) IF (USE_HDF5) ADD_SUBDIRECTORY(AbcConvert) ELSE() MESSAGE(STATUS "Skipping AbcConvert: it requires USE_HDF5") ENDIF() alembic-1.8.9/cmake/000077500000000000000000000000001507001531700142045ustar00rootroot00000000000000alembic-1.8.9/cmake/AlembicArnold.cmake000066400000000000000000000130241507001531700177020ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2013, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** # We shall worry about windowsification later. #-****************************************************************************** #-****************************************************************************** # FIRST, ARNOLD STUFF #-****************************************************************************** #-****************************************************************************** # If ARNOLD_ROOT not set, use predefined paths IF(NOT DEFINED ARNOLD_ROOT) IF ( ${CMAKE_HOST_UNIX} ) IF( ${DARWIN} ) # TODO: set to default install path when shipping out SET( ALEMBIC_ARNOLD_ROOT NOTFOUND ) ELSE() # TODO: set to default install path when shipping out SET( ALEMBIC_ARNOLD_ROOT "/sww/tools/arnold" ) ENDIF() ELSE() IF ( ${WINDOWS} ) # TODO: set to 32-bit or 64-bit path SET( ALEMBIC_ARNOLD_ROOT NOTFOUND ) ELSE() SET( ALEMBIC_ARNOLD_ROOT NOTFOUND ) ENDIF() ENDIF() ELSE() # Prefer ARNOLD_ROOT set from the CMakeCache'd variable than default paths SET( ALEMBIC_ARNOLD_ROOT ${ARNOLD_ROOT}) ENDIF() # Prefer ARNOLD_ROOT set from the environment over the CMakeCache'd variable IF(NOT $ENV{ARNOLD_ROOT}x STREQUAL "x") SET( ALEMBIC_ARNOLD_ROOT $ENV{ARNOLD_ROOT}) ENDIF() FIND_PATH( ALEMBIC_ARNOLD_INCLUDE_PATH ai.h PATHS "${ALEMBIC_ARNOLD_ROOT}/include" DOC "The directory where ai.h resides" ) SET( ALEMBIC_ARNOLD_LIBARNOLD ALEMBIC_ARNOLD_LIBARNOLD-NOTFOUND ) FIND_LIBRARY( ALEMBIC_ARNOLD_LIBARNOLD ai PATHS "${ALEMBIC_ARNOLD_ROOT}/lib/" "${ALEMBIC_ARNOLD_ROOT}/bin/" DOC "The ai library" ) IF( ${WINDOWS} ) SET( ARNOLD_COMPILE_FLAGS "/c /nologo /MT /TP /DWIN32" ) SET( ARNOLD_LINK_FLAGS "/nologo /dll /LIBPATH:\"%RMANTREE%\\lib\" libai.lib" ) ELSEIF( ${DARWIN} ) SET( ARNOLD_COMPILE_FLAGS "-c" ) SET( ARNOLD_LINK_FLAGS "-bundle -undefined dynamic_lookup" ) ELSEIF( ${LINUX} ) SET( ARNOLD_COMPILE_FLAGS "-c -fPIC" ) SET( ARNOLD_LINK_FLAGS "-shared" ) ENDIF() IF ( ( ${ALEMBIC_ARNOLD_INCLUDE_PATH} STREQUAL "ALEMBIC_ARNOLD_INCLUDE_PATH-NOTFOUND" ) OR ( ${ALEMBIC_ARNOLD_LIBARNOLD} STREQUAL "ALEMBIC_ARNOLD_LIBARNOLD-NOTFOUND" ) ) MESSAGE( STATUS "Arnold not found" ) SET( ALEMBIC_ARNOLD_FOUND FALSE ) ELSE() MESSAGE( STATUS "ARNOLD INCLUDE PATH: ${ALEMBIC_ARNOLD_INCLUDE_PATH}" ) MESSAGE( STATUS "libai: ${ALEMBIC_ARNOLD_LIBARNOLD}" ) SET( ALEMBIC_ARNOLD_FOUND TRUE ) SET( ALEMBIC_ARNOLD_LIBS ${ALEMBIC_ARNOLD_LIBARNOLD} ) ENDIF() ##-***************************************************************************** ##-***************************************************************************** # Macro for making arnold plugins ##-***************************************************************************** ##-***************************************************************************** MACRO(ADD_ARNOLD_CXX_PLUGIN PluginName SourceFile1 ) IF( NOT ${ALEMBIC_ARNOLD_FOUND} ) MESSAGE( FATAL_ERROR "Arnold is not found. :(" ) ENDIF() GET_FILENAME_COMPONENT( PluginNameNoDirectory ${PluginName} NAME ) GET_FILENAME_COMPONENT( PluginNameFullPath ${PluginName} ABSOLUTE ) SET( TMP_SOURCES ${SourceFile1} ${ARGN} ) SET( ${PluginName}_SOURCES ${TMP_SOURCES} ) INCLUDE_DIRECTORIES( ${ALEMBIC_ARNOLD_INCLUDE_PATH} ) ADD_LIBRARY( ${PluginName} MODULE ${TMP_SOURCES} ) SET_TARGET_PROPERTIES( ${PluginName} PROPERTIES COMPILE_FLAGS ${ARNOLD_COMPILE_FLAGS} LINK_FLAGS ${ARNOLD_LINK_FLAGS} PREFIX "" ) TARGET_LINK_LIBRARIES ( ${PluginName} ${ALEMBIC_ARNOLD_LIBARNOLD} ) ENDMACRO(ADD_ARNOLD_CXX_PLUGIN) alembic-1.8.9/cmake/AlembicHDF5.cmake000066400000000000000000000061751507001531700171620ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** # If you know the HDF5 root and there aren't any default versions of HDF5 in # the default system paths use: # cmake '-UHDF5_*' -DHDF5_ROOT:STRING= . # # For more info: # cmake --help-module FindHDF5 #-****************************************************************************** # FindHDF5 uses these as hints about search locations #-****************************************************************************** IF (DEFINED HDF5_ROOT) MESSAGE(STATUS "Using HDF5_ROOT: ${HDF5_ROOT}") # set HDF5_ROOT in the env so FindHDF5.cmake can find it SET(ENV{HDF5_ROOT} ${HDF5_ROOT}) ENDIF() #-****************************************************************************** # Find HDF5 #-****************************************************************************** SET(HDF5_USE_STATIC_LIBRARIES ${USE_STATIC_HDF5}) FIND_PACKAGE(HDF5 COMPONENTS C) #-****************************************************************************** # Wrap it all up #-****************************************************************************** IF (HDF5_FOUND) SET(ALEMBIC_HDF5_LIB ${HDF5_C_LIBRARIES}) SET(ALEMBIC_HDF5_HL_LIB ${HDF5_CXX_LIBRARIES}) MESSAGE(STATUS "HDF5_INCLUDE_DIRS: ${HDF5_INCLUDE_DIRS}") MESSAGE(STATUS "HDF5_LIBRARIES: ${HDF5_LIBRARIES}") ELSE() MESSAGE(STATUS "HDF5 not found.") ENDIF() alembic-1.8.9/cmake/AlembicMaya.cmake000066400000000000000000000206531507001531700173600ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2013, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** # If MAYA_ROOT not set, use predefined paths IF(NOT DEFINED MAYA_ROOT) IF ( ${CMAKE_HOST_UNIX} ) IF( ${DARWIN} ) # TODO: set to default install path when shipping out # SET( ALEMBIC_MAYA_ROOT NOTFOUND ) SET( ALEMBIC_MAYA_ROOT "/Applications/Autodesk/maya2012" ) SET( ALEMBIC_MAYA_INC_ROOT "/Applications/Autodesk/maya2012/include" ) SET( ALEMBIC_MAYA_LIB_ROOT "/Applications/Autodesk/maya2012/Maya.app/Contents/MacOS" ) ELSE() SET( ALEMBIC_MAYA_ROOT "/usr/autodesk/maya2012-x64" ) ENDIF() ELSE() IF ( ${WINDOWS} ) SET( ALEMBIC_MAYA_ROOT "C:/Program Files/Autodesk/Maya2012" ) ELSE() SET( ALEMBIC_MAYA_ROOT NOTFOUND ) ENDIF() ENDIF() ELSE() # Prefer MAYA_ROOT set from the CMakeCache'd variable than default paths MESSAGE( STATUS "Using MAYA_ROOT ${MAYA_ROOT}" ) SET( ALEMBIC_MAYA_ROOT ${MAYA_ROOT}) ENDIF() # Prefer MAYA_ROOT set from the environment over the CMakeCache'd variable IF(NOT $ENV{MAYA_ROOT}x STREQUAL "x") SET( ALEMBIC_MAYA_ROOT $ENV{MAYA_ROOT}) ENDIF() IF( NOT DEFINED ALEMBIC_MAYA_INC_ROOT ) SET( ALEMBIC_MAYA_INC_ROOT "${ALEMBIC_MAYA_ROOT}/include" ) ENDIF() IF( NOT DEFINED ALEMBIC_MAYA_LIB_ROOT ) IF ( ${DARWIN} ) SET( ALEMBIC_MAYA_LIB_ROOT "${ALEMBIC_MAYA_ROOT}/Maya.app/Contents/MacOS" ) ELSE() SET( ALEMBIC_MAYA_LIB_ROOT "${ALEMBIC_MAYA_ROOT}/lib" ) ENDIF() ENDIF() MESSAGE( STATUS "Maya lib root: ${ALEMBIC_MAYA_LIB_ROOT}" ) # Just start with forcing it to ILM's location SET( MAYA_INCLUDE_PATH MAYA_INCLUDE_PATH-NOTFOUND ) FIND_PATH( MAYA_INCLUDE_PATH maya/MTypes.h PATHS "${ALEMBIC_MAYA_INC_ROOT}" "${ALEMBIC_MAYA_ROOT}/include" "${ALEMBIC_MAYA_ROOT}/devkit/include" DOC "The directory where MTypes.h resides" ) SET( MAYA_FOUNDATION_LIBRARY MAYA_FOUNDATION_LIBRARY-NOTFOUND ) FIND_LIBRARY( MAYA_FOUNDATION_LIBRARY Foundation PATHS "${ALEMBIC_MAYA_LIB_ROOT}" "${ALEMBIC_MAYA_ROOT}/lib" DOC "The directory where Foundation.lib resides" ) SET( MAYA_OPENMAYA_LIBRARY MAYA_OPENMAYA_LIBRARY-NOTFOUND ) FIND_LIBRARY( MAYA_OPENMAYA_LIBRARY OpenMaya PATHS "${ALEMBIC_MAYA_LIB_ROOT}" "${ALEMBIC_MAYA_ROOT}/lib" DOC "The directory where OpenMaya.lib resides" ) SET( MAYA_OPENMAYAANIM_LIBRARY MAYA_OPENMAYAANIM_LIBRARY-NOTFOUND ) FIND_LIBRARY( MAYA_OPENMAYAANIM_LIBRARY OpenMayaAnim PATHS "${ALEMBIC_MAYA_LIB_ROOT}" "${ALEMBIC_MAYA_ROOT}/lib" DOC "The directory where OpenMayaAnim.lib resides" ) SET( MAYA_OPENMAYAFX_LIBRARY MAYA_OPENMAYAFX_LIBRARY-NOTFOUND ) FIND_LIBRARY( MAYA_OPENMAYAFX_LIBRARY OpenMayaFX PATHS "${ALEMBIC_MAYA_LIB_ROOT}" "${ALEMBIC_MAYA_ROOT}/lib" DOC "The directory where OpenMayaFX.lib resides" ) SET( MAYA_OPENMAYARENDER_LIBRARY MAYA_OPENMAYARENDER_LIBRARY-NOTFOUND ) FIND_LIBRARY( MAYA_OPENMAYARENDER_LIBRARY OpenMayaRender PATHS "${ALEMBIC_MAYA_LIB_ROOT}" "${ALEMBIC_MAYA_ROOT}/lib" DOC "The directory where OpenMayaRender.lib resides" ) SET( MAYA_OPENMAYAUI_LIBRARY MAYA_OPENMAYAUI_LIBRARY-NOTFOUND ) FIND_LIBRARY( MAYA_OPENMAYAUI_LIBRARY OpenMayaUI PATHS "${ALEMBIC_MAYA_LIB_ROOT}" "${ALEMBIC_MAYA_ROOT}/lib" DOC "The directory where OpenMayaUI.lib resides" ) SET( MAYA_LIBRARIES ${MAYA_FOUNDATION_LIBRARY} ${MAYA_OPENMAYA_LIBRARY} ${MAYA_OPENMAYAANIM_LIBRARY} ${MAYA_OPENMAYAFX_LIBRARY} ${MAYA_OPENMAYARENDER_LIBRARY} ${MAYA_OPENMAYAUI_LIBRARY} ) IF ( NOT WINDOWS ) IF ( NOT DARWIN ) SET ( MAYA_EXTENSION ".so" ) SET( MAYA_COMPILE_FLAGS "-m64 -g -pthread -pipe -D_BOOL -DLINUX -DLINUX_64 -DREQUIRE_IOSTREAM -fPIC -Wno-deprecated -fno-gnu-keywords" ) SET( MAYA_LINK_FLAGS "-shared -m64 -g -pthread -pipe -D_BOOL -DLINUX -DLINUX_64 -DREQUIRE_IOSTREAM -fPIC -Wno-deprecated -fno-gnu-keywords -Wl,-Bsymbolic" ) ELSE() #SET( MAYA_COMPILE_FLAGS # "-DAW_NEW_IOSTREAMS -DCC_GNU_ -DOSMac_ -DOSMacOSX_ -DBits32_ \ # -DOSMac_MachO_ -DREQUIRE_IOSTREAM -fno-gnu-keywords -fpascal-strings \ #-arch i386 -D_LANGUAGE_C_PLUS_PLUS" ) \ SET ( MAYA_EXTENSION ".bundle" ) SET( MAYA_COMPILE_FLAGS "-DAW_NEW_IOSTREAMS -DCC_GNU_ -DOSMac_ -DOSMacOSX_ -DOSMac_MachO_ -DREQUIRE_IOSTREAM -fno-gnu-keywords -D_LANGUAGE_C_PLUS_PLUS" ) SET( MAYA_LINK_FLAGS #"-dynamic -g -fPIC " #"-shared -g -fPIC " "-fno-gnu-keywords -framework System -framework SystemConfiguration -framework CoreServices -framework Carbon -framework Cocoa -framework ApplicationServices -framework Quicktime -framework IOKit -bundle -fPIC -L${ALEMBIC_MAYA_LIB_ROOT} -Wl,-executable_path,${ALEMBIC_MAYA_LIB_ROOT}" ) ENDIF() ELSE() SET( MAYA_EXTENSION ".mll" ) SET( MAYA_COMPILE_FLAGS "/MD /D \"NT_PLUGIN\" /D \"REQUIRE_IOSTREAM\" /D \"_BOOL\"" ) SET( MAYA_LINK_FLAGS " /export:initializePlugin /export:uninitializePlugin " ) ENDIF() #-****************************************************************************** #-****************************************************************************** # Wrap it all ups #-****************************************************************************** #-****************************************************************************** IF( MAYA_INCLUDE_PATH ) # SET( MAYA_FOUND 1 CACHE STRING "Set to 1 if Maya is found, 0 otherwise" ) SET( MAYA_FOUND 1 ) MESSAGE( STATUS "Found Maya!" ) ELSE( MAYA_INCLUDE_PATH ) SET( MAYA_FOUND 0 CACHE STRING "Set to 1 if Maya is found, 0 otherwise" ) MESSAGE( STATUS "Could not find Maya." ) ENDIF( MAYA_INCLUDE_PATH ) #MARK_AS_ADVANCED( MAYA_FOUND ) #-****************************************************************************** #-****************************************************************************** # Macros for making maya plugins #-****************************************************************************** #-****************************************************************************** MACRO(ADD_MAYA_CXX_PLUGIN PluginName SourceFile1 ) IF( NOT ${MAYA_FOUND} ) MESSAGE( FATAL_ERROR "Could not find Maya. " ) ENDIF() # Get various filename permutations GET_FILENAME_COMPONENT( PluginNameNoDirectory ${PluginName} NAME ) GET_FILENAME_COMPONENT( PluginNameFullPath ${PluginName} ABSOLUTE ) # Set a variable for sources SET( TMP_SOURCES ${SourceFile1} ${ARGN} ) SET( ${PluginName}_SOURCES ${TMP_SOURCES} ) # Include the maya dirs INCLUDE_DIRECTORIES( ${MAYA_INCLUDE_PATH} ) # Add the target ADD_LIBRARY( ${PluginName} MODULE ${TMP_SOURCES} ) # Compile and linker flags SET_TARGET_PROPERTIES( ${PluginName} PROPERTIES COMPILE_FLAGS ${MAYA_COMPILE_FLAGS} LINK_FLAGS ${MAYA_LINK_FLAGS} PREFIX "" SUFFIX ${MAYA_EXTENSION} ) # Link the target TARGET_LINK_LIBRARIES( ${PluginName} ${MAYA_LIBRARIES} ) ENDMACRO(ADD_MAYA_CXX_PLUGIN) alembic-1.8.9/cmake/AlembicPRMan.cmake000066400000000000000000000135231507001531700174440ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2011, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** # We shall worry about windowsification later. #-****************************************************************************** #-****************************************************************************** # FIRST, PRMAN STUFF #-****************************************************************************** #-****************************************************************************** # If PRMAN_ROOT not set, use predefined paths IF(NOT DEFINED PRMAN_ROOT) IF ( ${CMAKE_HOST_UNIX} ) IF( ${DARWIN} ) # TODO: set to default install path when shipping out SET( ALEMBIC_PRMAN_ROOT NOTFOUND ) ELSE() # TODO: set to default install path when shipping out SET( ALEMBIC_PRMAN_ROOT "/sww/tools/pixar/rman15" ) ENDIF() ELSE() IF ( ${WINDOWS} ) # TODO: set to 32-bit or 64-bit path SET( ALEMBIC_PRMAN_ROOT NOTFOUND ) ELSE() SET( ALEMBIC_PRMAN_ROOT NOTFOUND ) ENDIF() ENDIF() ELSE() # Prefer PRMAN_ROOT set from the CMakeCache'd variable than default paths SET( ALEMBIC_PRMAN_ROOT ${PRMAN_ROOT}) ENDIF() # Prefer PRMAN_ROOT set from the environment over the CMakeCache'd variable IF(NOT $ENV{PRMAN_ROOT}x STREQUAL "x") SET( ALEMBIC_PRMAN_ROOT $ENV{PRMAN_ROOT}) ENDIF() FIND_PATH( ALEMBIC_PRMAN_INCLUDE_PATH ri.h PATHS "${ALEMBIC_PRMAN_ROOT}/include" DOC "The directory where ri.h resides" ) SET( ALEMBIC_PRMAN_LIBPRMAN ALEMBIC_PRMAN_LIBPRMAN-NOTFOUND ) FIND_LIBRARY( ALEMBIC_PRMAN_LIBPRMAN prman PATHS "${ALEMBIC_PRMAN_ROOT}/lib/" DOC "The prman library" ) IF( ${WINDOWS} ) SET( PRMAN_COMPILE_FLAGS "/c /nologo /MT /TP /DWIN32" ) SET( PRMAN_LINK_FLAGS "/nologo /dll /LIBPATH:\"%RMANTREE%\\lib\" libprman.lib" ) ELSEIF( ${DARWIN} ) SET( PRMAN_COMPILE_FLAGS "-c" ) SET( PRMAN_LINK_FLAGS "-bundle -undefined dynamic_lookup" ) ELSEIF( ${LINUX} ) SET( PRMAN_COMPILE_FLAGS "-c -fPIC" ) SET( PRMAN_LINK_FLAGS "-shared" ) ENDIF() IF ( ( ${ALEMBIC_PRMAN_INCLUDE_PATH} STREQUAL "ALEMBIC_PRMAN_INCLUDE_PATH-NOTFOUND" ) OR ( ${ALEMBIC_PRMAN_LIBPRMAN} STREQUAL "ALEMBIC_PRMAN_LIBPRMAN-NOTFOUND" ) ) MESSAGE( STATUS "PRMan not found" ) SET( ALEMBIC_PRMAN_FOUND FALSE ) ELSE() MESSAGE( STATUS "PRMAN INCLUDE PATH: ${ALEMBIC_PRMAN_INCLUDE_PATH}" ) MESSAGE( STATUS "libprman: ${ALEMBIC_PRMAN_LIBPRMAN}" ) SET( ALEMBIC_PRMAN_FOUND TRUE ) SET( ALEMBIC_PRMAN_LIBS ${ALEMBIC_PRMAN_LIBPRMAN} ) ENDIF() ##-***************************************************************************** ##-***************************************************************************** # Macro for making prman plugins ##-***************************************************************************** ##-***************************************************************************** MACRO(ADD_PRMAN_CXX_PLUGIN PluginName SourceFile1 ) IF( NOT ${ALEMBIC_PRMAN_FOUND} ) MESSAGE( FATAL_ERROR "PRMan is not found. :(" ) ENDIF() GET_FILENAME_COMPONENT( PluginNameNoDirectory ${PluginName} NAME ) GET_FILENAME_COMPONENT( PluginNameFullPath ${PluginName} ABSOLUTE ) SET( TMP_SOURCES ${SourceFile1} ${ARGN} ) SET( ${PluginName}_SOURCES ${TMP_SOURCES} ) INCLUDE_DIRECTORIES( ${ALEMBIC_PRMAN_INCLUDE_PATH} ) ADD_LIBRARY( ${PluginName} MODULE ${TMP_SOURCES} ) SET_TARGET_PROPERTIES( ${PluginName} PROPERTIES COMPILE_FLAGS ${PRMAN_COMPILE_FLAGS} LINK_FLAGS ${PRMAN_LINK_FLAGS} PREFIX "" ) TARGET_LINK_LIBRARIES ( ${PluginName} ${ALEMBIC_PRMAN_LIBPRMAN} ) # TARGET_LINK_LIBRARIES( ${PluginName} # AlembicTraitsGeom AlembicTraits # AlembicAsset MD5Hash AlembicHDF5 # ${ALEMBIC_HDF5_LIBS} AlembicUtil AlembicExc # ${Boost_REGEX_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} # ${Boost_SYSTEM_LIBRARY} # -lpthread -lz -lm ) ENDMACRO(ADD_PRMAN_CXX_PLUGIN) alembic-1.8.9/cmake/AlembicPyIlmBase.cmake000066400000000000000000000045631507001531700203200ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2016, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** SET(PYTHON_VERSION_MAJOR ${PYALEMBIC_PYTHON_MAJOR}) SET(PYTHON_VERSION_MINOR ${Python${PYALEMBIC_PYTHON_MAJOR}_VERSION_MINOR}) SET(PYTHON_INCLUDE_DIR ${Python${PYTHON_VERSION_MAJOR}_INCLUDE_DIRS}) FIND_PACKAGE(Imath COMPONENTS PyImath) IF (Imath_FOUND) SET(ALEMBIC_PYIMATH_LIB Imath::PyImath) ELSE() # Fallback for older versions of Imath 3 and 3.1 FIND_PACKAGE(Imath) SET(ALEMBIC_PYIMATH_LIB Imath::PyImath_Python${PYTHON_VERSION_MAJOR}_${PYTHON_VERSION_MINOR}) MESSAGE(STATUS "Found package Imath using: ${ALEMBIC_PYIMATH_LIB}") ENDIF()alembic-1.8.9/cmake/valgrind-python.supp000066400000000000000000000173461507001531700202550ustar00rootroot00000000000000# # This is a valgrind suppression file that should be used when using valgrind. # # Here's an example of running valgrind: # # cd python/dist/src # valgrind --tool=memcheck --suppressions=Misc/valgrind-python.supp \ # ./python -E -tt ./Lib/test/regrtest.py -u bsddb,network # # You must edit Objects/obmalloc.c and uncomment Py_USING_MEMORY_DEBUGGER # to use the preferred suppressions with Py_ADDRESS_IN_RANGE. # # If you do not want to recompile Python, you can uncomment # suppressions for PyObject_Free and PyObject_Realloc. # # See Misc/README.valgrind for more information. # # Originally from: http://svn.python.org/projects/python/trunk/Misc/valgrind-python.supp # all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif { ADDRESS_IN_RANGE/Invalid read of size 4 Memcheck:Addr4 fun:Py_ADDRESS_IN_RANGE } { ADDRESS_IN_RANGE/Invalid read of size 4 Memcheck:Value4 fun:Py_ADDRESS_IN_RANGE } { ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64) Memcheck:Value8 fun:Py_ADDRESS_IN_RANGE } { ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value Memcheck:Cond fun:Py_ADDRESS_IN_RANGE } # # Leaks (including possible leaks) # Hmmm, I wonder if this masks some real leaks. I think it does. # Will need to fix that. # { Suppress leaking the GIL. Happens once per process, see comment in ceval.c. Memcheck:Leak fun:malloc fun:PyThread_allocate_lock fun:PyEval_InitThreads } { Suppress leaking the GIL after a fork. Memcheck:Leak fun:malloc fun:PyThread_allocate_lock fun:PyEval_ReInitThreads } { Suppress leaking the autoTLSkey. This looks like it shouldn't leak though. Memcheck:Leak fun:malloc fun:PyThread_create_key fun:_PyGILState_Init fun:Py_InitializeEx fun:Py_Main } { Hmmm, is this a real leak or like the GIL? Memcheck:Leak fun:malloc fun:PyThread_ReInitTLS } { Handle PyMalloc confusing valgrind (possibly leaked) Memcheck:Leak fun:realloc fun:_PyObject_GC_Resize fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING } { Handle PyMalloc confusing valgrind (possibly leaked) Memcheck:Leak fun:malloc fun:_PyObject_GC_New fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING } { Handle PyMalloc confusing valgrind (possibly leaked) Memcheck:Leak fun:malloc fun:_PyObject_GC_NewVar fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING } # # Non-python specific leaks # { Handle pthread issue (possibly leaked) Memcheck:Leak fun:calloc fun:allocate_dtv fun:_dl_allocate_tls_storage fun:_dl_allocate_tls } { Handle pthread issue (possibly leaked) Memcheck:Leak fun:memalign fun:_dl_allocate_tls_storage fun:_dl_allocate_tls } { ADDRESS_IN_RANGE/Invalid read of size 4 Memcheck:Addr4 fun:PyObject_Free } { ADDRESS_IN_RANGE/Invalid read of size 4 Memcheck:Value4 fun:PyObject_Free } { ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value Memcheck:Cond fun:PyObject_Free } { ADDRESS_IN_RANGE/Invalid read of size 4 Memcheck:Addr4 fun:PyObject_Realloc } { ADDRESS_IN_RANGE/Invalid read of size 4 Memcheck:Value4 fun:PyObject_Realloc } { ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value Memcheck:Cond fun:PyObject_Realloc } ### ### All the suppressions below are for errors that occur within libraries ### that Python uses. The problems to not appear to be related to Python's ### use of the libraries. ### { Generic ubuntu ld problems Memcheck:Addr8 obj:/lib/ld-2.4.so obj:/lib/ld-2.4.so obj:/lib/ld-2.4.so obj:/lib/ld-2.4.so } { Generic gentoo ld problems Memcheck:Cond obj:/lib/ld-2.3.4.so obj:/lib/ld-2.3.4.so obj:/lib/ld-2.3.4.so obj:/lib/ld-2.3.4.so } { DBM problems, see test_dbm Memcheck:Param write(buf) fun:write obj:/usr/lib/libdb1.so.2 obj:/usr/lib/libdb1.so.2 obj:/usr/lib/libdb1.so.2 obj:/usr/lib/libdb1.so.2 fun:dbm_close } { DBM problems, see test_dbm Memcheck:Value8 fun:memmove obj:/usr/lib/libdb1.so.2 obj:/usr/lib/libdb1.so.2 obj:/usr/lib/libdb1.so.2 obj:/usr/lib/libdb1.so.2 fun:dbm_store fun:dbm_ass_sub } { DBM problems, see test_dbm Memcheck:Cond obj:/usr/lib/libdb1.so.2 obj:/usr/lib/libdb1.so.2 obj:/usr/lib/libdb1.so.2 fun:dbm_store fun:dbm_ass_sub } { DBM problems, see test_dbm Memcheck:Cond fun:memmove obj:/usr/lib/libdb1.so.2 obj:/usr/lib/libdb1.so.2 obj:/usr/lib/libdb1.so.2 obj:/usr/lib/libdb1.so.2 fun:dbm_store fun:dbm_ass_sub } { GDBM problems, see test_gdbm Memcheck:Param write(buf) fun:write fun:gdbm_open } { ZLIB problems, see test_gzip Memcheck:Cond obj:/lib/libz.so.1.2.3 obj:/lib/libz.so.1.2.3 fun:deflate } { Avoid problems w/readline doing a putenv and leaking on exit Memcheck:Leak fun:malloc fun:xmalloc fun:sh_set_lines_and_columns fun:_rl_get_screen_size fun:_rl_init_terminal_io obj:/lib/libreadline.so.4.3 fun:rl_initialize } ### ### These occur from somewhere within the SSL, when running ### test_socket_sll. They are too general to leave on by default. ### ###{ ### somewhere in SSL stuff ### Memcheck:Cond ### fun:memset ###} ###{ ### somewhere in SSL stuff ### Memcheck:Value4 ### fun:memset ###} ### ###{ ### somewhere in SSL stuff ### Memcheck:Cond ### fun:MD5_Update ###} ### ###{ ### somewhere in SSL stuff ### Memcheck:Value4 ### fun:MD5_Update ###} # # All of these problems come from using test_socket_ssl # { from test_socket_ssl Memcheck:Cond fun:BN_bin2bn } { from test_socket_ssl Memcheck:Cond fun:BN_num_bits_word } { from test_socket_ssl Memcheck:Value4 fun:BN_num_bits_word } { from test_socket_ssl Memcheck:Cond fun:BN_mod_exp_mont_word } { from test_socket_ssl Memcheck:Cond fun:BN_mod_exp_mont } { from test_socket_ssl Memcheck:Param write(buf) fun:write obj:/usr/lib/libcrypto.so.0.9.7 } { from test_socket_ssl Memcheck:Cond fun:RSA_verify } { from test_socket_ssl Memcheck:Value4 fun:RSA_verify } { from test_socket_ssl Memcheck:Value4 fun:DES_set_key_unchecked } { from test_socket_ssl Memcheck:Value4 fun:DES_encrypt2 } { from test_socket_ssl Memcheck:Cond obj:/usr/lib/libssl.so.0.9.7 } { from test_socket_ssl Memcheck:Value4 obj:/usr/lib/libssl.so.0.9.7 } { from test_socket_ssl Memcheck:Cond fun:BUF_MEM_grow_clean } { from test_socket_ssl Memcheck:Cond fun:memcpy fun:ssl3_read_bytes } { from test_socket_ssl Memcheck:Cond fun:SHA1_Update } { from test_socket_ssl Memcheck:Value4 fun:SHA1_Update } # # By design, zlib does not initialize all variables which leads # to this warning. This is reported on zlib FAQ: # http://www.zlib.net/zlib_faq.html#faq36 # { zlib does not initialize all variables Memcheck:Cond fun: longest_match fun: deflate_slow fun: deflate } { H5Dclose conditional read of uninitialized value Memcheck:Cond obj:/usr/lib64/libz.so.1.2.3 obj:/usr/lib64/libz.so.1.2.3 fun:deflate fun:compress2 fun:H5Z_filter_deflate fun:H5Z_pipeline fun:H5D_chunk_flush_entry fun:H5D_chunk_flush fun:H5D_flush_real fun:H5D_close fun:H5I_dec_ref fun:H5Dclose } { ADDRESS_IN_RANGE/Invalid read of size 8 Memcheck:Addr8 fun:PyObject_Free } { ADDRESS_IN_RANGE/Invalid read of size 8 Memcheck:Value8 fun:PyObject_Free } { ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value Memcheck:Cond fun:__strcpy_chk } { ADDRESS_IN_RANGE/Invalid read of size 8 Memcheck:Addr8 fun:PyObject_Realloc } { ADDRESS_IN_RANGE/Invalid read of size 8 Memcheck:Value8 fun:PyObject_Realloc } alembic-1.8.9/examples/000077500000000000000000000000001507001531700147425ustar00rootroot00000000000000alembic-1.8.9/examples/AbcClients/000077500000000000000000000000001507001531700167515ustar00rootroot00000000000000alembic-1.8.9/examples/AbcClients/CMakeLists.txt000066400000000000000000000036761507001531700215250ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks, Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Sony Pictures Imageworks, nor ## Industrial Light & Magic nor the names of their contributors may be used ## to endorse or promote products derived from this software without specific ## prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/examples") ADD_SUBDIRECTORY(WFObjConvert) alembic-1.8.9/examples/AbcClients/WFObjConvert/000077500000000000000000000000001507001531700212615ustar00rootroot00000000000000alembic-1.8.9/examples/AbcClients/WFObjConvert/AbcReader.cpp000066400000000000000000000162271507001531700236050ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace AbcClients { namespace WFObjConvert { //-***************************************************************************** void AbcReader::parsingEnd( const std::string &iStreamName, size_t iNumLines ) { makeCurrentObject(); } //-***************************************************************************** void AbcReader::v( index_t iIndex, const V3d &iPoint ) { assert( ( index_t ) ( m_vertices.size()+1 ) == iIndex ); V3f pt( iPoint.x, iPoint.y, iPoint.z ); m_vertices.push_back( pt ); } //-***************************************************************************** void AbcReader::vt( index_t iIndex, double iVal ) { assert( ( index_t ) ( m_texVertices.size()+1 ) == iIndex ); V2f t( iVal, 0.0f ); m_texVertices.push_back( t ); } //-***************************************************************************** void AbcReader::vt( index_t iIndex, const V2d& iVal ) { assert( ( index_t ) ( m_texVertices.size()+1 ) == iIndex ); V2f t( iVal.x, iVal.y ); m_texVertices.push_back( t ); } //-***************************************************************************** void AbcReader::vt( index_t iIndex, const V3d& iVal ) { assert( ( index_t ) ( m_texVertices.size()+1 ) == iIndex ); V2f t( iVal.x, iVal.y ); m_texVertices.push_back( t ); } //-***************************************************************************** void AbcReader::vn( index_t iIndex, const V3d& iVal ) { assert( ( index_t ) ( m_normals.size()+1 ) == iIndex ); N3f n( iVal.x, iVal.y, iVal.z ); m_normals.push_back( n ); } //-***************************************************************************** void AbcReader::f( const IndexVec &vIndices, const IndexVec &vtIndices, const IndexVec &vnIndices ) { size_t count = vIndices.size(); if ( count > 2 ) { m_counts.push_back( count ); for ( size_t i = 0; i < count; ++i ) { m_indices.push_back( ( int )( vIndices[i]-1 ) ); } if ( vtIndices.size() == count ) { for ( size_t i = 0; i < count; ++i ) { m_texIndices.push_back( ( int )( vtIndices[i]-1 ) ); } } if ( vnIndices.size() == count ) { for ( size_t i = 0; i < count; ++i ) { m_normIndices.push_back( ( int )( vnIndices[i]-1 ) ); } } } } //-***************************************************************************** void AbcReader::activeObject( const std::string &iObjectName ) { makeCurrentObject(); m_currentObjectName = iObjectName; } //-***************************************************************************** void AbcReader::makeCurrentObject() { if ( m_vertices.size() > 3 && m_indices.size() > 3 && m_counts.size() > 1 && m_currentObjectName.length() && !m_parentObject.getChildHeader( m_currentObjectName ) ) { OPolyMesh meshObj( m_parentObject, m_currentObjectName ); OPolyMeshSchema &mesh = meshObj.getSchema(); OPolyMeshSchema::Sample psamp; psamp.setPositions( V3fArraySample( m_vertices ) ); psamp.setFaceIndices( Int32ArraySample( m_indices ) ); psamp.setFaceCounts( Int32ArraySample( m_counts ) ); // Set facevarying UVs if they exist. std::vector fvTexVerts; if ( m_texIndices.size() == m_indices.size() && m_texVertices.size() > 0 ) { V2f defunct( 0.0f, 0.0f ); size_t N = m_texVertices.size(); size_t NI = m_texIndices.size(); fvTexVerts.resize( NI ); for ( size_t i = 0; i < NI; ++i ) { int tindex = m_texIndices[i]; if ( tindex < 0 || (size_t) tindex >= N ) { fvTexVerts[i] = defunct; } else { fvTexVerts[i] = m_texVertices[tindex]; } } psamp.setUVs( OV2fGeomParam::Sample( fvTexVerts, kFacevaryingScope ) ); } // Set facevarying normals if they exist. std::vector fvNormals; if ( m_normIndices.size() == m_indices.size() && m_normals.size() > 0 ) { N3f defunct( 0.0f, 0.0f, 0.0f ); size_t N = m_normals.size(); size_t NI = m_normIndices.size(); fvNormals.resize( NI ); for ( size_t i = 0; i < NI; ++i ) { int nindex = m_normIndices[i]; if ( nindex < 0 || (size_t) nindex >= N ) { fvNormals[i] = defunct; } else { fvNormals[i] = m_normals[nindex]; } } psamp.setNormals( ON3fGeomParam::Sample( fvNormals, kFacevaryingScope ) ); } mesh.set( psamp ); } m_indices.clear(); m_texIndices.clear(); m_normIndices.clear(); m_counts.clear(); m_currentObjectName = ""; } } // End namespace WFObjConvert } // End namespace AbcClients alembic-1.8.9/examples/AbcClients/WFObjConvert/AbcReader.h000066400000000000000000000073771507001531700232600ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef AbcClients_WFObjConvert_AbcReader_h #define AbcClients_WFObjConvert_AbcReader_h #include #include #include namespace AbcClients { namespace WFObjConvert { //-***************************************************************************** // For now, just going to create vertices, indices, and counts. will // worry about the rest later. class ABC_WFOBJ_CONVERT_EXPORT AbcReader : public Reader { public: AbcReader( OObject &iParentObject, const std::string &iDefaultObjectName = "OBJ_polymesh" ) : Reader() , m_parentObject( iParentObject ) , m_defaultObjectName( iDefaultObjectName ) , m_currentObjectName( iDefaultObjectName ) {} virtual void parsingEnd( const std::string &iStreamName, size_t iNumLines ); virtual void v( index_t iIndex, const V3d &iVal ); virtual void vt( index_t iIndex, double iVal ); virtual void vt( index_t iIndex, const V2d &iVal ); virtual void vt( index_t iIndex, const V3d &iVal ); virtual void vn( index_t iIndex, const V3d &iVal ); virtual void f( const IndexVec &iVertexIndices, const IndexVec &iTextureIndices, const IndexVec &iNormalIndices ); virtual void activeObject( const std::string &iObjectName ); protected: void makeCurrentObject(); OObject m_parentObject; std::string m_defaultObjectName; std::string m_currentObjectName; std::vector m_vertices; std::vector m_texVertices; std::vector m_normals; std::vector m_indices; std::vector m_texIndices; std::vector m_normIndices; std::vector m_counts; }; } // End namespace WFObjConvert } // End namespace AbcClients #endif alembic-1.8.9/examples/AbcClients/WFObjConvert/All.h000066400000000000000000000042401507001531700221420ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef AbcClients_WFObjConvert_All_h #define AbcClients_WFObjConvert_All_h #include #include #include #include #include #endif alembic-1.8.9/examples/AbcClients/WFObjConvert/CMakeLists.txt000066400000000000000000000057231507001531700240300ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks, Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Sony Pictures Imageworks, nor ## Industrial Light & Magic nor the names of their contributors may be used ## to endorse or promote products derived from this software without specific ## prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** SET(CXX_FILES AbcReader.cpp ParseReader.cpp Parser.cpp Reader.cpp) SET(PUBLIC_H_FILES AbcReader.h All.h Export.h Foundation.h Parser.h Reader.h) SET(PRIVATE_H_FILES ParseReader.h) SET(H_FILES ${PUBLIC_H_FILES} ${PRIVATE_H_FILES}) SET(SOURCE_FILES ${CXX_FILES} ${H_FILES}) ADD_LIBRARY(AbcWFObjConvert ${LIB_TYPE} ${SOURCE_FILES}) TARGET_LINK_LIBRARIES(AbcWFObjConvert Alembic::Alembic) IF(ALEMBIC_SHARED_LIBS) SET_TARGET_PROPERTIES(AbcWFObjConvert PROPERTIES DEFINE_SYMBOL ABC_WFOBJ_CONVERT_EXPORTS) ENDIF() INSTALL(TARGETS AbcWFObjConvert LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) INSTALL(FILES ${PUBLIC_H_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Alembic/AbcClients/WFObjConvert PERMISSIONS OWNER_READ GROUP_READ WORLD_READ) IF (USE_TESTS AND USE_HDF5) ADD_SUBDIRECTORY(Tests) ELSE() MESSAGE(STATUS "Skipping WFObjConvert tests: requires USE_TESTS and USE_HDF5") ENDIF() alembic-1.8.9/examples/AbcClients/WFObjConvert/Export.h000066400000000000000000000045611507001531700227210ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef AbcClients_WFObjConvert_Export_h #define AbcClients_WFObjConvert_Export_h #if defined(ALEMBIC_DLL) #if defined(ABC_WFOBJ_CONVERT_EXPORTS) #define ABC_WFOBJ_CONVERT_EXPORT __declspec(dllexport) #else #define ABC_WFOBJ_CONVERT_EXPORT __declspec(dllimport) #endif #define ABC_WFOBJ_CONVERT_EXPORT_CONST #else #define ABC_WFOBJ_CONVERT_EXPORT __attribute__ ((visibility ("default"))) #define ABC_WFOBJ_CONVERT_EXPORT_CONST const #endif #endif /* AbcClients_WFObjConvert_Export_h */ alembic-1.8.9/examples/AbcClients/WFObjConvert/Foundation.h000066400000000000000000000053371507001531700235500ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef AbcClients_WFObjConvert_Foundation_h #define AbcClients_WFObjConvert_Foundation_h #include #include #include #include #include #include #include #include #include #include // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace AbcClients { namespace WFObjConvert { namespace AbcG = ::Alembic::AbcGeom; using namespace AbcG; } // End namespace WFObjConvert } // End namespace AbcClients #endif alembic-1.8.9/examples/AbcClients/WFObjConvert/ParseReader.cpp000066400000000000000000000316341507001531700241710ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include namespace AbcClients { namespace WFObjConvert { //-***************************************************************************** #define FAIL( TEXT ) \ do \ { \ std::stringstream sstr; \ sstr << TEXT; \ ::std::runtime_error exc( sstr.str() ); \ throw( exc ); \ } \ while( 0 ) //-***************************************************************************** ParseReader::ParseReader( Reader &iReader ) : m_readInto( iReader ) , m_numV( 1 ) // vertex 0 is special , m_numVt( 1 ) // vertex 0 is special , m_numVn( 1 ) // vertex 0 is special , m_numVp( 1 ) // vertex 0 is special { // Nothing } //-***************************************************************************** void ParseReader::start( const std::string &iStreamName ) { m_readInto.parsingBegin( iStreamName ); } //-***************************************************************************** void ParseReader::error( const std::string &iStreamName, const std::string &iError, size_type iLine ) { m_readInto.parsingError( iStreamName, iError, ( size_t )iLine ); } //-***************************************************************************** void ParseReader::finish( const std::string &iStreamName, size_type iNumLines ) { m_readInto.parsingEnd( iStreamName, ( size_t )iNumLines ); } //-***************************************************************************** void ParseReader::v( std::vector const & vals ) { size_t numV = vals.size(); index_t vIdx = ( index_t )m_numV; if ( numV == 3 ) { m_readInto.v( vIdx, V3d( vals[0], vals[1], vals[2] ) ); } else if ( numV == 4 ) { m_readInto.v( vIdx, V3d( vals[0], vals[1], vals[2] ), vals[3] ); } else { FAIL( "vertices must have 3 or 4 doubles" ); } ++m_numV; } //-***************************************************************************** void ParseReader::vt( std::vector const & vals ) { size_t numV = vals.size(); index_t vtIdx = ( index_t )m_numVt; if ( numV == 1 ) { m_readInto.vt( vtIdx, vals[0] ); } else if ( numV == 2 ) { m_readInto.vt( vtIdx, V2d( vals[0], vals[1] ) ); } else if ( numV == 3 ) { m_readInto.vt( vtIdx, V3d( vals[0], vals[1], vals[2] ) ); } else { FAIL( "texture vertices must have 1, 2, or 3 doubles" ); } ++m_numVt; } //-***************************************************************************** void ParseReader::vn( std::vector const & vals ) { size_t numV = vals.size(); index_t vnIdx = ( index_t )m_numVn; if ( numV == 3 ) { m_readInto.vn( vnIdx, V3d( vals[0], vals[1], vals[2] ) ); } else { FAIL( "normals must have 3 doubles" ); } ++m_numVn; } //-***************************************************************************** void ParseReader::vp( std::vector const & vals ) { size_t numV = vals.size(); index_t vpIdx = ( index_t )m_numVp; if ( numV == 1 ) { m_readInto.vp( vpIdx, vals[0] ); } else if ( numV == 2 ) { m_readInto.vp( vpIdx, V2d( vals[0], vals[1] ) ); } else { FAIL( "param vertices must have 1 or 2 doubles" ); } ++m_numVp; } //-***************************************************************************** void ParseReader::f( std::vector const &vals ) { Reader::IndexVec vIndices; Reader::IndexVec vtIndices; Reader::IndexVec vnIndices; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { index_t v = ( index_t )(*iter).x; index_t vt = ( index_t )(*iter).y; index_t vn = ( index_t )(*iter).z; if ( v < 1 || v >= ( index_t )m_numV ) { FAIL( "Invalid vertex index: " << v << ", must be 0 < v < " << m_numV ); } vIndices.push_back( v ); if ( vt != -1 ) { if ( vt < 1 || vt >= ( index_t )m_numVt ) { FAIL( "Invalid texture vertex index: " << vt << ", must be 0 < vt < " << m_numVt ); } vtIndices.push_back( vt ); } if ( vn != -1 ) { if ( vn < 1 || vn >= ( index_t )m_numVn ) { FAIL( "Invalid normal vertex index: " << vn << ", must be 0 < vn < " << m_numVn ); } vnIndices.push_back( vn ); } } if ( vIndices.size() < 3 ) { FAIL( "Insufficient number of face vertices: " << vIndices.size() ); } if ( ( vtIndices.size() != 0 && vtIndices.size() != vIndices.size() ) || ( vnIndices.size() != 0 && vnIndices.size() != vIndices.size() ) ) { FAIL( "Improper mixed use of vertex/texture/normal syntax." ); } m_readInto.f( vIndices, vtIndices, vnIndices ); } //-***************************************************************************** void ParseReader::l( std::vector const &vals ) { Reader::IndexVec vIndices; Reader::IndexVec vtIndices; Reader::IndexVec vnIndices; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { index_t v = ( index_t )(*iter).x; index_t vt = ( index_t )(*iter).y; index_t vn = ( index_t )(*iter).z; if ( v < 1 || v >= ( index_t )m_numV ) { FAIL( "Invalid vertex index: " << v << ", must be 0 < v < " << m_numV ); } vIndices.push_back( v ); if ( vt != -1 ) { if ( vt < 1 || vt >= ( index_t )m_numVt ) { FAIL( "Invalid texture vertex index: " << vt << ", must be 0 < vt < " << m_numVt ); } vtIndices.push_back( vt ); } if ( vn != -1 ) { if ( vn < 1 || vn >= ( index_t )m_numVn ) { FAIL( "Invalid normal vertex index: " << vn << ", must be 0 < vn < " << m_numVn ); } vnIndices.push_back( vn ); } } if ( vIndices.size() < 2 ) { FAIL( "Insufficient number of line vertices: " << vIndices.size() ); } if ( ( vtIndices.size() != 0 && vtIndices.size() != vIndices.size() ) || ( vnIndices.size() != 0 && vnIndices.size() != vIndices.size() ) ) { FAIL( "Improper mixed use of vertex/texture/normal syntax." ); } m_readInto.l( vIndices, vtIndices, vnIndices ); } //-***************************************************************************** void ParseReader::p( std::vector const &vals ) { Reader::IndexVec vIndices; Reader::IndexVec vtIndices; Reader::IndexVec vnIndices; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { index_t v = ( index_t )(*iter).x; index_t vt = ( index_t )(*iter).y; index_t vn = ( index_t )(*iter).z; if ( v < 1 || v >= ( index_t )m_numV ) { FAIL( "Invalid vertex index: " << v << ", must be 0 < v < " << m_numV ); } vIndices.push_back( v ); if ( vt != -1 ) { if ( vt < 1 || vt >= ( index_t )m_numVt ) { FAIL( "Invalid texture vertex index: " << vt << ", must be 0 < vt < " << m_numVt ); } vtIndices.push_back( vt ); } if ( vn != -1 ) { if ( vn < 1 || vn >= ( index_t )m_numVn ) { FAIL( "Invalid normal vertex index: " << vn << ", must be 0 < vn < " << m_numVn ); } vnIndices.push_back( vn ); } } if ( ( vtIndices.size() != 0 && vtIndices.size() != vIndices.size() ) || ( vnIndices.size() != 0 && vnIndices.size() != vIndices.size() ) ) { FAIL( "Improper mixed use of vertex/texture/normal syntax." ); } m_readInto.p( vIndices, vtIndices, vnIndices ); } //-***************************************************************************** void ParseReader::g( std::vector const &vals ) { for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { if ( m_groups.count( (*iter) ) < 1 ) { m_groups.insert( (*iter) ); m_readInto.newGroup( (*iter) ); } } m_readInto.activeGroups( vals ); } //-***************************************************************************** void ParseReader::o( std::string const &val ) { m_readInto.activeObject( val ); } //-***************************************************************************** void ParseReader::mtllib( std::string const &val ) { m_readInto.mtllib( val ); } //-***************************************************************************** void ParseReader::maplib( std::string const &val ) { m_readInto.maplib( val ); } //-***************************************************************************** void ParseReader::usemtl( std::string const &val ) { m_readInto.usemtl( val ); } //-***************************************************************************** void ParseReader::usemap( std::string const &val ) { m_readInto.usemap( val ); } //-***************************************************************************** void ParseReader::trace_obj( std::string const &val ) { m_readInto.trace_obj( val ); } //-***************************************************************************** void ParseReader::shadow_obj( std::string const &val ) { m_readInto.shadow_obj( val ); } //-***************************************************************************** void ParseReader::bevel( bool b ) { m_readInto.bevel( b ); } //-***************************************************************************** void ParseReader::cinterp( bool b ) { m_readInto.cinterp( b ); } //-***************************************************************************** void ParseReader::dinterp( bool b ) { m_readInto.dinterp( b ); } //-***************************************************************************** void ParseReader::sB( bool b ) { m_readInto.smoothingGroup( ( int )b ); } //-***************************************************************************** void ParseReader::s( int s ) { m_readInto.smoothingGroup( s ); } //-***************************************************************************** void ParseReader::lod( int l ) { m_readInto.lod( l ); } } // End namespace WFObjConvert } // End namespace AbcClients alembic-1.8.9/examples/AbcClients/WFObjConvert/ParseReader.h000066400000000000000000000101101507001531700236200ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef AbcClients_WFObjConvert_ParseReader_h #define AbcClients_WFObjConvert_ParseReader_h //-***************************************************************************** // Breaking my rules here about Foundation.h, to minimize recompiling // of the parser, which takes FOREVER. Stupid templates. #include #include #include #include #include namespace AbcClients { namespace WFObjConvert { //-***************************************************************************** // This is a helper class used by the parser, that redirects input into // the virtual reader class. class Reader; typedef long long pindex_t; //-***************************************************************************** class ParseReader { public: typedef Imath::Vec3 V3idx; typedef std::vector::size_type size_type; ParseReader( Reader &iReadInto ); void start( const std::string &iStringName ); void error( const std::string &iStringName, const std::string &iError, size_type iLine ); void finish( const std::string &iStringName, size_type iNumLines ); void v( std::vector const & vals ); void vt( std::vector const & vals ); void vn( std::vector const & vals ); void vp( std::vector const & vals ); void f( std::vector const &vals ); void l( std::vector const &vals ); void p( std::vector const &vals ); void g( std::vector const &vals ); void o( std::string const &val ); void mtllib( std::string const &val ); void maplib( std::string const &val ); void usemtl( std::string const &val ); void usemap( std::string const &val ); void trace_obj( std::string const &val ); void shadow_obj( std::string const &val ); void bevel( bool b ); void cinterp( bool b ); void dinterp( bool b ); void sB( bool b ); void s( int s ); void lod( int l ); protected: Reader &m_readInto; size_type m_numV; size_type m_numVt; size_type m_numVn; size_type m_numVp; std::set m_groups; }; } // End namespace WFObjConvert } // End namespace AbcClients #endif alembic-1.8.9/examples/AbcClients/WFObjConvert/Parser.cpp000066400000000000000000000322301507001531700232210ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include //-***************************************************************************** // I'm breaking with the Alembic "Foundation" and "FoundationPrivate" // conventions here because I want to limit the exposure to these files, // as they take FOREVER to parse/compile, because of all the template-hoo-haa. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace AbcClients { namespace WFObjConvert { //-***************************************************************************** // Create a namespace to hide the parser stuff in. // Following spirit convention, calling this 'client' namespace client { // Bring in all the pieces we need. namespace qi = boost::spirit::qi; namespace ascii = boost::spirit::ascii; namespace phoenix = boost::phoenix; using qi::double_; using qi::int_; using qi::long_long; using qi::phrase_parse; using qi::_1; using qi::_val; using qi::lit; using qi::eol; using qi::eps; using qi::lexeme; using qi::attr; using ascii::space; using ascii::space_type; using ascii::char_; using ascii::string; using phoenix::ref; using phoenix::push_back; //-***************************************************************************** // Symbol table for 'on off' struct onOff_ : qi::symbols { onOff_() { add ( "on" , true ) ( "On" , true ) ( "ON" , true ) ( "true", true ) ( "True", true ) ( "TRUE" , true ) ( "off", false ) ( "Off", false ) ( "OFF", false ) ( "false", false ) ( "False", false ) ( "FALSE", false ) ; } }; //-***************************************************************************** typedef boost::fusion::vector index_triplet; //-***************************************************************************** // Create a local parse reader that uses the boost::fusion index-triplet. class LclParseReader : public ParseReader { public: LclParseReader( Reader &iReadInto ) : ParseReader( iReadInto ) {} LclParseReader( const ParseReader &iCopy ) : ParseReader( iCopy ) {} static V3idx toV3( index_triplet const &iVal ) { return V3idx( ( pindex_t )boost::fusion::at_c<0>( iVal ), ( pindex_t )boost::fusion::at_c<1>( iVal ), ( pindex_t )boost::fusion::at_c<2>( iVal ) ); } void f_( std::vector const &vals ) { std::vector cvt; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { cvt.push_back( toV3(*iter) ); } this->f( cvt ); } void l_( std::vector const &vals ) { std::vector cvt; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { cvt.push_back( toV3(*iter) ); } this->l( cvt ); } void p_( std::vector const &vals ) { std::vector cvt; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { cvt.push_back( toV3(*iter) ); } this->p( cvt ); } }; //-***************************************************************************** typedef std::string::const_iterator Iterator; //-***************************************************************************** // This grammar parses OBJ's different styles of index-triplets. // template struct indexTriplet : qi::grammar { qi::rule start; #define LL long_long indexTriplet() : indexTriplet::base_type( start ) { //start = lexeme[( ( LL >> attr( -1 ) >> attr( -1 ) ) | // ( LL >> '/' >> LL >> '/' >> LL ) | // ( LL >> '/' >> LL >> attr( -1 ) ) | // ( LL >> '/' >> attr(-1) >> '/' >> LL ) )]; start = lexeme[( ( LL >> '/' >> LL >> '/' >> LL ) | ( LL >> '/' >> attr( -1 ) >> '/' >> LL ) | ( LL >> '/' >> LL >> '/' >> attr( -1 ) ) | ( LL >> attr( -1 ) >> attr( -1 ) ) )]; } #undef LL }; //-***************************************************************************** // REAL PARSE FUNCTION void doParseOBJ( Reader &iReadInto, const std::string &iName, std::istream &iStream ) { // Create an index-triplet parser, call it "IDX" //indexTriplet IDX; indexTriplet IDX; // Create a 'space-less' name parser. qi::rule STR = lexeme[+(char_)]; // Make an on-off symbol table onOff_ ON_OFF; // Create types of rules. the PT_RULE is one which reads point // declarations. typedef qi::rule(), space_type> PT_RULE; // The ELEM_RULE is one which reads element declarations with // lists of index triplets. typedef qi::rule(), space_type> ELEM_RULE; // The NAME RULE is one which reads a single name typedef qi::rule NAME_RULE; // The NAMES_RULE is one which reads lists of names typedef qi::rule(), space_type> NAMES_RULE; // The BOOL_RULE is one which reads 'on' or 'off' or 'true' or 'false' // or 'ON' or 'OFF' ... etc. typedef qi::rule BOOL_RULE; // The INT_RULE is one which reads a single int typedef qi::rule INT_RULE; // The REACT macro binds the result of a successfully parsed rule // to a member function of the PreReader LclParseReader preReader( iReadInto ); #define REACT( F ) boost::bind( &LclParseReader:: F , &preReader, ::_1 ) // Declare our rules. PT_RULE VERTEX = "v" >> +(double_); PT_RULE VTEX = "vt" >> +(double_); PT_RULE VNORM = "vn" >> +(double_); PT_RULE VPARAM = "vp" >> +(double_); ELEM_RULE FACE = "f" >> IDX >> IDX >> +(IDX); ELEM_RULE LINE = "l" >> IDX >> +(IDX); ELEM_RULE POINT = "p" >> +(IDX); NAMES_RULE GROUP = "g" >> +(STR); NAME_RULE OBJECT = "o" >> (STR); NAME_RULE MTLLIB = "mtllib" >> STR; NAME_RULE MAPLIB = "maplib" >> STR; NAME_RULE USEMAP = "usemap" >> STR; NAME_RULE USEMTL = "usemtl" >> STR; NAME_RULE TRACE_OBJ = "trace_obj" >> STR; NAME_RULE SHADOW_OBJ = "shadow_obj" >> STR; BOOL_RULE BEVEL = "bevel" >> ON_OFF; BOOL_RULE CINTERP = "cinterp" >> ON_OFF; BOOL_RULE DINTERP = "dinterp" >> ON_OFF; BOOL_RULE SMOOTHB = "s" >> ON_OFF; INT_RULE SMOOTHI = "s" >> int_; INT_RULE LOD = "lod" >> int_; qi::rule ALL = qi::omit[ ( VERTEX[REACT(v)] | VTEX[REACT(vt)] | VNORM[REACT(vn)] | VPARAM[REACT(vp)] | FACE[REACT(f_)] | LINE[REACT(l_)] | POINT[REACT(p_)] | GROUP[REACT(g)] | OBJECT[REACT(o)] | MTLLIB[REACT(mtllib)] | MAPLIB[REACT(maplib)] | USEMTL[REACT(usemtl)] | USEMAP[REACT(usemap)] | TRACE_OBJ[REACT(trace_obj)] | SHADOW_OBJ[REACT(shadow_obj)] | BEVEL[REACT(bevel)] | CINTERP[REACT(cinterp)] | DINTERP[REACT(dinterp)] | SMOOTHB[REACT(sB)] | SMOOTHI[REACT(s)] | LOD[REACT(lod)] | // Comments ( '#' >> *(char_) ) ) ]; //-************************************************************************* // BEGIN THE PARSING! //-************************************************************************* preReader.start( iName ); std::string str; size_t lineCount = 1; while ( std::getline( iStream, str ) ) { if ( iStream.eof() ) { break; } if ( str.empty() ) { continue; } std::string::const_iterator iter = str.begin(); std::string::const_iterator end = str.end(); try { //bool r = client::parseObjLine( iter, end, reader ); bool r = phrase_parse( iter, end, ALL, space ); if ( !r ) { std::runtime_error exc( "Syntax Error" ); throw( exc ); } ++lineCount; } catch ( std::exception &exc ) { std::stringstream sstr; sstr << "ERROR: OBJ stream \"" << iName << "\": " << std::endl << "LINE: " << lineCount << std::endl << "---> " << str << std::endl << "REASON: " << exc.what() << std::endl; preReader.error( iName, sstr.str(), lineCount ); return; } catch ( ... ) { std::stringstream sstr; sstr << "ERROR: OBJ stream \"" << iName << "\": " << std::endl << "LINE: " << lineCount << std::endl << "---> " << str << std::endl; preReader.error( iName, sstr.str(), lineCount ); return; } } preReader.finish( iName, lineCount ); } } // End namespace client //-***************************************************************************** // PARSE FUNCTION void ParseOBJ( Reader &iReadInto, const std::string &iName, std::istream &iStream ) { client::doParseOBJ( iReadInto, iName, iStream ); } //-***************************************************************************** void ParseOBJ( Reader &iReadInto, const std::string &iFileName ) { std::ifstream fStr( iFileName.c_str() ); if ( !fStr ) { ParseReader reader( iReadInto ); reader.start( iFileName ); std::stringstream sstr; sstr << "ERROR: OBJ stream \"" << iFileName << "\": " << std::endl << "Couldn't open file: " << iFileName << std::endl; reader.error( iFileName, sstr.str(), 0 ); return; } ParseOBJ( iReadInto, iFileName, fStr ); } } // End namespace WFObjConvert } // End namespace AbcClients alembic-1.8.9/examples/AbcClients/WFObjConvert/Parser.h000066400000000000000000000046301507001531700226710ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include namespace AbcClients { namespace WFObjConvert { //-***************************************************************************** ABC_WFOBJ_CONVERT_EXPORT void ParseOBJ( Reader &iReadInto, const std::string &iName, std::istream &iStream ); ABC_WFOBJ_CONVERT_EXPORT void ParseOBJ( Reader &iReadInto, const std::string &iFileName ); } // End namespace AbcClients } // End namespace WFObjConvert alembic-1.8.9/examples/AbcClients/WFObjConvert/Reader.cpp000066400000000000000000000043571507001531700232000ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace AbcClients { namespace WFObjConvert { //-***************************************************************************** void Reader::v( index_t iIndex, const V3d &iPt, double iW ) { if ( iW != 0.0 ) { this->v( iIndex, iPt/iW ); } else { this->v( iIndex, iPt ); } } } // End namespace WFObjConvert } // End namespace AbcClients alembic-1.8.9/examples/AbcClients/WFObjConvert/Reader.h000066400000000000000000000227601507001531700226430ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef AbcClients_WFObjConvert_Reader_h #define AbcClients_WFObjConvert_Reader_h #include #include namespace AbcClients { namespace WFObjConvert { //-***************************************************************************** // This class definition is taken from Gto/WFObj. //-***************************************************************************** //-***************************************************************************** //! The Reader class is an abstract base class which represents the //! actions which may occur in the parsing of a Wavefront OBJ file. //! As the file or stream is parsed, each of these actions will be called //! as their corresponding actions are encountered in the file. The //! default behavior is to ignore everything. //! Because the files being read are ascii, they can actually represent //! arbitrary precision. Therefore, the Reader is implemented in double //! precision for maximum accuracy. class ABC_WFOBJ_CONVERT_EXPORT Reader { public: typedef std::vector IndexVec; typedef std::vector StringVec; //! In current ilm-base, there is no Vec4. //! By default, we will treat 4-dimensional //! points as homogenous and dehomogenize them, subsequently //! calling the V3d version of 'v' //! Default constructor does nothing //! ... Reader() {} //! Virtual destructor as support for derived classes. //! ... virtual ~Reader() {} //! This function is called by the parser //! when parsing begins. //! The argument passed is a name for the stream - in the //! case of a file, it will be the file name; otherwise it //! will be an identifier of some kind. virtual void parsingBegin( const std::string &iStreamName ) {} //! This function is called by the parser //! if an error has occurred, causing parsing to stop. //! An error description and a line number are given. virtual void parsingError( const std::string &iStreamName, const std::string &iErrorDesc, size_t iErrorLine ) {} //! This function is called by the parser //! when parsing ends. The name passed in will match //! the name passed to the begin function. virtual void parsingEnd( const std::string &iStreamName, size_t iNumLinesParsed ) {} //-************************************************************************* //! POINT DECLARATION //! Points may be of type: //! "v", which are 3 or 4-dimensional points, //! "vt", which are 1, 2, or 3 dimensional texture coordinates, //! "vn", which are 3-dimensional normals, //! "vp", which are 'parameter coordinates'. Unclear what these are for. //! These functions will each also be passed the integer index that //! they correspond to, for synchronization and checking. //! OBJ files begin with the first vertex at index '1', allowing for //! vertex "0" to be used as a special location. //-************************************************************************* //! Set a three-dimensional vertex. //! ... virtual void v( index_t iIndex, const V3d &iVal ) {} //! Set a 4-dimensional vertex, interpreted as homogenous. //! The default behavior is to dehomogenize and call the 3-dim version. //! It will not divide by zero - it will leave the point alone in that //! case. virtual void v( index_t iIndex, const V3d &iVal, double iW ); //! Set a 1-dimensional texture vertex. //! ... virtual void vt( index_t iIndex, double iVal ) {} //! Set a 2-dimensional texture vertex. //! ... virtual void vt( index_t iIndex, const V2d &iVal ) {} //! Set a 3-dimensional texture vertex. //! ... virtual void vt( index_t iIndex, const V3d &iVal ) {} //! Set a 3-dimensional normal. //! Using V3d instead of N3f/N3T virtual void vn( index_t iIndex, const V3d &iVal ) {} //! Set a 1-dimensional parameter vertex. //! ... virtual void vp( index_t iIndex, double iVal ) {} //! Set a 2-dimensional parameter vertex. //! ... virtual void vp( index_t iIndex, const V2d &iVal ) {} //-************************************************************************* //! ELEMENT DECLARATION //! In this Parser/Reader, we have three types of elements. //! They are "faces", "lines", and "points". //! points can actually have multiple points. //! An element consists of vectors of Vertex, Normal, and Texture //! indices. If these indices were unspecified, the vectors will be empty. //! The vertex indices will always be non-empty //-************************************************************************* //! Declare a face. //! ... virtual void f( const IndexVec &iVertexIndices, const IndexVec &iTextureIndices, const IndexVec &iNormalIndices ) {} //! Declare a polyline. //! ... virtual void l( const IndexVec &iVertexIndices, const IndexVec &iTextureIndices, const IndexVec &iNormalIndices ) {} //! Declare a point-set. //! ... virtual void p( const IndexVec &iVertexIndices, const IndexVec &iTextureIndices, const IndexVec &iNormalIndices ) {} //-************************************************************************* //! GROUPS AND OBJECT DECLARATION //! OBJ files have the ability to assign objects to groups, multiple //! groups at a time, and also to declare elements as belonging to //! a particular named object. //-************************************************************************* //! Called when an as-yet unseen group name is encountered. //! ... virtual void newGroup( const std::string &iGroupName ) {} //! Called when active groups change //! The set of groups may be more than 1. virtual void activeGroups( const StringVec &iGroupNames ) {} //! Called when an "o" line is encountered. //! ... virtual void activeObject( const std::string &iObjectName ) {} //! Called when smoothing group changes -- note that Id == 0 means //! no smoothing -- this is equivalent to the "s off" statement. //! the "s on" statement will set smoothing group to 1. virtual void smoothingGroup( int iSmoothingGroup ) {} //-************************************************************************* // Bevel/cinterp/dinterp //-************************************************************************* virtual void bevel( bool ) {} virtual void cinterp( bool ) {} virtual void dinterp( bool ) {} //-************************************************************************* // Material and map //-************************************************************************* virtual void mtllib( const std::string &iName ) {} virtual void maplib( const std::string &iName ) {} virtual void usemap( const std::string &iName ) {} virtual void usemtl( const std::string &iName ) {} //-************************************************************************* // Trace/Shadow objects //-************************************************************************* virtual void trace_obj( const std::string &iName ) {} virtual void shadow_obj( const std::string& iName ) {} //-************************************************************************* // Level of detail number //-************************************************************************* virtual void lod( int ) {} }; } // End namespace WFObjConvert } // End namespace AbcClients #endif alembic-1.8.9/examples/AbcClients/WFObjConvert/Tests/000077500000000000000000000000001507001531700223635ustar00rootroot00000000000000alembic-1.8.9/examples/AbcClients/WFObjConvert/Tests/CMakeLists.txt000066400000000000000000000046221507001531700251270ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** SET(TEST_LIBS AbcWFObjConvert Alembic::Alembic ${HDF5_LIBRARIES} Imath::Imath) ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES} ${EXTERNAL_MATH_LIBS} ) #ADD_EXECUTABLE(WFObjConvert_ParserTest parserTest.cpp) ADD_EXECUTABLE(WFObjConvert_ParserTest test1.cpp) TARGET_LINK_LIBRARIES(WFObjConvert_ParserTest ${TEST_LIBS}) ADD_EXECUTABLE(WFObjConvert_obj2abc test2.cpp) TARGET_LINK_LIBRARIES( WFObjConvert_obj2abc ${TEST_LIBS}) #ADD_TEST(AbcClients_WFObjConvert_Parser_TEST WFObjConvert_ParserTest) #ADD_TEST(AbcClients_WFObjConvert_obj2abc_TEST WFObjConvert_obj2abc) alembic-1.8.9/examples/AbcClients/WFObjConvert/Tests/parserTest.cpp000066400000000000000000000316421507001531700252310ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #include #include #include #include #include #include namespace client { namespace qi = boost::spirit::qi; namespace ascii = boost::spirit::ascii; namespace phoenix = boost::phoenix; using qi::double_; using qi::int_; using qi::long_long; using qi::phrase_parse; using qi::_1; using qi::_val; using qi::lit; using qi::eol; using qi::eps; using qi::lexeme; using qi::attr; using ascii::space; using ascii::space_type; using ascii::char_; using ascii::string; using phoenix::ref; using phoenix::push_back; //-***************************************************************************** // Symbol table for 'on off' struct onOff_ : qi::symbols { onOff_() { add ( "on" , true ) ( "On" , true ) ( "ON" , true ) ( "true", true ) ( "True", true ) ( "TRUE" , true ) ( "off", false ) ( "Off", false ) ( "OFF", false ) ( "false", false ) ( "False", false ) ( "FALSE", false ) ; } }; //-***************************************************************************** // Define a 'parser index', which is a long-long. typedef long long pindex_t; typedef Imath::Vec3 V3idx; //-***************************************************************************** typedef boost::fusion::vector index_triplet; inline V3idx toV3( index_triplet const &iVal ) { return V3idx( boost::fusion::at_c<0>( iVal ), boost::fusion::at_c<1>( iVal ), boost::fusion::at_c<2>( iVal ) ); } //-***************************************************************************** struct PreReader { void v( std::vector const & vals ) { std::cout << "FOUND v "; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { std::cout << (*iter) << " "; } std::cout << std::endl; } void vt( std::vector const & vals ) { std::cout << "FOUND vt "; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { std::cout << (*iter) << " "; } std::cout << std::endl; } void vn( std::vector const & vals ) { std::cout << "FOUND vn "; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { std::cout << (*iter) << " "; } std::cout << std::endl; } void vp( std::vector const & vals ) { std::cout << "FOUND vp "; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { std::cout << (*iter) << " "; } std::cout << std::endl; } void f( std::vector const &vals ) { std::cout << "FOUND f "; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { std::cout << toV3(*iter) << " "; } std::cout << std::endl; } void l( std::vector const &vals ) { std::cout << "FOUND l, size = " << vals.size() << std::endl; } void p( std::vector const &vals ) { std::cout << "FOUND p, size = " << vals.size() << std::endl; } void g( std::vector const &vals ) { std::cout << "FOUND g "; for ( std::vector::const_iterator iter = vals.begin(); iter != vals.end(); ++iter ) { std::cout << (*iter) << " "; } std::cout << std::endl; } void o( std::string const &val ) { std::cout << "FOUND o " << val << std::endl; } void mtllib( std::string const &val ) { std::cout << "FOUND mtllib " << val << std::endl; } void maplib( std::string const &val ) { std::cout << "FOUND maplib " << val << std::endl; } void usemtl( std::string const &val ) { std::cout << "FOUND usemtl " << val << std::endl; } void usemap( std::string const &val ) { std::cout << "FOUND usemap " << val << std::endl; } void trace_obj( std::string const &val ) { std::cout << "FOUND trace_obj " << val << std::endl; } void shadow_obj( std::string const &val ) { std::cout << "FOUND shadow)obj " << val << std::endl; } void bevel( bool b ) { std::cout << "BEVEL: " << b << std::endl; } void cinterp( bool b ) { std::cout << "CINTERP: " << b << std::endl; } void dinterp( bool b ) { std::cout << "DINTERP: " << b << std::endl; } void sB( bool b ) { std::cout << "smooth: " << b << std::endl; } void s( int s ) { std::cout << "smooth: " << s << std::endl; } void lod( int l ) { std::cout << "lod: " << l << std::endl; } }; //-***************************************************************************** template struct indexTriplet : qi::grammar { qi::rule start; #define LL long_long indexTriplet() : indexTriplet::base_type( start ) { start = lexeme[( ( LL >> '/' >> LL >> '/' >> LL ) | ( LL >> '/' >> LL >> attr( -1 ) ) | ( LL >> '/' >> attr(-1) >> '/' >> LL ) )]; } #undef LL }; //-***************************************************************************** // This parses one line of an OBJ file, accumulating results into the reader. template bool parseObjLine( Iterator iFirst, Iterator iLast, PreReader& iPreReader ) { // Create an index-triplet parser, call it "IDX" indexTriplet IDX; // Create a 'space-less' name parser. qi::rule STR = lexeme[+(char_)]; // Make an on-off symbol table onOff_ ON_OFF; // Create types of rules. the PT_RULE is one which reads point // declarations. typedef qi::rule(), space_type> PT_RULE; // The ELEM_RULE is one which reads element declarations with // lists of index triplets. typedef qi::rule(), space_type> ELEM_RULE; // The NAME RULE is one which reads a single name typedef qi::rule NAME_RULE; // The NAMES_RULE is one which reads lists of names typedef qi::rule(), space_type> NAMES_RULE; // The BOOL_RULE is one which reads 'on' or 'off' or 'true' or 'false' // or 'ON' or 'OFF' ... etc. typedef qi::rule BOOL_RULE; // The INT_RULE is one which reads a single int typedef qi::rule INT_RULE; // The REACT macro binds the result of a successfully parsed rule // to a member function of the PreReader #define REACT( F ) boost::bind( &PreReader:: F , &iPreReader, ::_1 ) // Declare our rules. PT_RULE VERTEX = "v" >> +(double_); PT_RULE VTEX = "vt" >> +(double_); PT_RULE VNORM = "vn" >> +(double_); PT_RULE VPARAM = "vp" >> +(double_); ELEM_RULE FACE = "f" >> IDX >> IDX >> +(IDX); ELEM_RULE LINE = "l" >> IDX >> +(IDX); ELEM_RULE POINT = "p" >> +(IDX); NAMES_RULE GROUP = "g" >> +(STR); NAME_RULE OBJECT = "o" >> (STR); NAME_RULE MTLLIB = "mtllib" >> STR; NAME_RULE MAPLIB = "maplib" >> STR; NAME_RULE USEMAP = "usemap" >> STR; NAME_RULE USEMTL = "usemtl" >> STR; NAME_RULE TRACE_OBJ = "trace_obj" >> STR; NAME_RULE SHADOW_OBJ = "shadow_obj" >> STR; BOOL_RULE BEVEL = "bevel" >> ON_OFF; BOOL_RULE CINTERP = "cinterp" >> ON_OFF; BOOL_RULE DINTERP = "dinterp" >> ON_OFF; BOOL_RULE SMOOTHB = "s" >> ON_OFF; INT_RULE SMOOTHI = "s" >> int_; INT_RULE LOD = "lod" >> int_; // Parse the rules! bool r = phrase_parse( iFirst, iLast, ( VERTEX[REACT(v)] | VTEX[REACT(vt)] | VNORM[REACT(vn)] | VPARAM[REACT(vp)] | FACE[REACT(f)] | LINE[REACT(l)] | POINT[REACT(p)] | GROUP[REACT(g)] | OBJECT[REACT(o)] | MTLLIB[REACT(mtllib)] | MAPLIB[REACT(maplib)] | USEMTL[REACT(usemtl)] | USEMAP[REACT(usemap)] | TRACE_OBJ[REACT(trace_obj)] | SHADOW_OBJ[REACT(shadow_obj)] | BEVEL[REACT(bevel)] | CINTERP[REACT(cinterp)] | DINTERP[REACT(dinterp)] | SMOOTHB[REACT(sB)] | SMOOTHI[REACT(s)] | LOD[REACT(lod)] | // Comments ( '#' >> *(char_) ) ), space ); if ( !r || iFirst != iLast ) { return false; } return true; } } // End namespace client /////////////////////////////////////////////////////////////////////////////// // Main program /////////////////////////////////////////////////////////////////////////////// int main() { std::cout << "/////////////////////////////////////////////////////////\n\n"; std::cout << "\t\tRoman Numerals Parser\n\n"; std::cout << "/////////////////////////////////////////////////////////\n\n"; std::cout << "Type a Roman Numeral ...or [q or Q] to quit\n\n"; typedef std::string::const_iterator iterator_type; std::string str; while ( std::getline( std::cin, str ) ) { if (str.empty() || str[0] == 'q' || str[0] == 'Q') break; std::string::const_iterator iter = str.begin(); std::string::const_iterator end = str.end(); client::PreReader reader; bool r = client::parseObjLine(iter, end, reader); if ( r ) { std::cout << "-------------------------\n"; std::cout << "Parsing succeeded\n"; std::cout << "-------------------------\n"; } else { std::cout << "Parsing failed, man." << std::endl; } } std::cout << "Bye... :-) \n\n"; return 0; } alembic-1.8.9/examples/AbcClients/WFObjConvert/Tests/parserTestWorked.cpp000066400000000000000000000156661507001531700264150ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #include namespace client { namespace qi = boost::spirit::qi; namespace ascii = boost::spirit::ascii; /////////////////////////////////////////////////////////////////////////////// // Parse roman hundreds (100..900) numerals using the symbol table. // Notice that the data associated with each slot is the parser's attribute // (which is passed to attached semantic actions). /////////////////////////////////////////////////////////////////////////////// //[tutorial_roman_hundreds struct hundreds_ : qi::symbols { hundreds_() { add ("C" , 100) ("CC" , 200) ("CCC" , 300) ("CD" , 400) ("D" , 500) ("DC" , 600) ("DCC" , 700) ("DCCC" , 800) ("CM" , 900) ; } } hundreds; //] /////////////////////////////////////////////////////////////////////////////// // Parse roman tens (10..90) numerals using the symbol table. /////////////////////////////////////////////////////////////////////////////// //[tutorial_roman_tens struct tens_ : qi::symbols { tens_() { add ("X" , 10) ("XX" , 20) ("XXX" , 30) ("XL" , 40) ("L" , 50) ("LX" , 60) ("LXX" , 70) ("LXXX" , 80) ("XC" , 90) ; } } tens; //] /////////////////////////////////////////////////////////////////////////////// // Parse roman ones (1..9) numerals using the symbol table. /////////////////////////////////////////////////////////////////////////////// //[tutorial_roman_ones struct ones_ : qi::symbols { ones_() { add ("I" , 1) ("II" , 2) ("III" , 3) ("IV" , 4) ("V" , 5) ("VI" , 6) ("VII" , 7) ("VIII" , 8) ("IX" , 9) ; } } ones; //] /////////////////////////////////////////////////////////////////////////////// // roman (numerals) grammar // // Note the use of the || operator. The expression // a || b reads match a or b and in sequence. Try // defining the roman numerals grammar in YACC or // PCCTS. Spirit rules! :-) /////////////////////////////////////////////////////////////////////////////// //[tutorial_roman_grammar template struct roman : qi::grammar { roman() : roman::base_type(start) { using qi::eps; using qi::lit; using qi::_val; using qi::_1; using ascii::char_; start = eps [_val = 0] >> ( +lit('M') [_val += 1000] || hundreds [_val += _1] || tens [_val += _1] || ones [_val += _1] ) ; } qi::rule start; }; //] } /////////////////////////////////////////////////////////////////////////////// // Main program /////////////////////////////////////////////////////////////////////////////// int main() { std::cout << "/////////////////////////////////////////////////////////\n\n"; std::cout << "\t\tRoman Numerals Parser\n\n"; std::cout << "/////////////////////////////////////////////////////////\n\n"; std::cout << "Type a Roman Numeral ...or [q or Q] to quit\n\n"; typedef std::string::const_iterator iterator_type; typedef client::roman roman; roman roman_parser; // Our grammar std::string str; unsigned result; while ( std::getline( std::cin, str ) ) { if (str.empty() || str[0] == 'q' || str[0] == 'Q') break; std::string::const_iterator iter = str.begin(); std::string::const_iterator end = str.end(); //[tutorial_roman_grammar_parse bool r = parse(iter, end, roman_parser, result); if (r && iter == end) { std::cout << "-------------------------\n"; std::cout << "Parsing succeeded\n"; std::cout << "result = " << result << std::endl; std::cout << "-------------------------\n"; } else { std::string rest(iter, end); std::cout << "-------------------------\n"; std::cout << "Parsing failed\n"; std::cout << "stopped at: \": " << rest << "\"\n"; std::cout << "-------------------------\n"; } //] } std::cout << "Bye... :-) \n\n"; return 0; } alembic-1.8.9/examples/AbcClients/WFObjConvert/Tests/test1.cpp000066400000000000000000000055471507001531700241420ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include namespace OBJ = AbcClients::WFObjConvert; class MyReader : public OBJ::Reader { public: virtual void parsingError( const std::string &iStreamName, const std::string &iErrorDesc, size_t iErrorLine ) { std::cerr << iErrorDesc << std::endl; exit( -1 ); } virtual void parsingEnd( const std::string &iStreamName, size_t iNumLines ) { std::cout << "Parsed OBJ File: " << iStreamName << ", num lines parsed: " << iNumLines << std::endl; } }; //-***************************************************************************** int main( int argc, char *argv[] ) { if ( argc != 2 ) { std::cerr << "USAGE: " << argv[0] << " " << std::endl; return -1; } MyReader reader; OBJ::ParseOBJ( reader, argv[1] ); return 0; } alembic-1.8.9/examples/AbcClients/WFObjConvert/Tests/test2.cpp000066400000000000000000000071101507001531700241270ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #include namespace OBJ = AbcClients::WFObjConvert; namespace Abc = Alembic::AbcGeom; class MyReader : public OBJ::AbcReader { public: MyReader( Abc::OObject &iParentObj ) : OBJ::AbcReader( iParentObj ) {} MyReader( Abc::OObject &iParentObj, const std::string &iDfltName ) : OBJ::AbcReader( iParentObj, iDfltName ) {} virtual void parsingError( const std::string &iStreamName, const std::string &iErrorDesc, size_t iErrorLine ) { std::cerr << iErrorDesc << std::endl; exit( -1 ); } virtual void parsingEnd( const std::string &iStreamName, size_t iNumLines ) { OBJ::AbcReader::parsingEnd( iStreamName, iNumLines ); std::cout << "Parsed OBJ File: " << iStreamName << ", num lines parsed: " << iNumLines << std::endl; } }; //-***************************************************************************** int main( int argc, char *argv[] ) { if ( argc != 3 ) { std::cerr << "USAGE: " << argv[0] << " " << std::endl; return -1; } try { Abc::OArchive archive( Alembic::AbcCoreHDF5::WriteArchive(), argv[2] ); Abc::OObject topObj( archive, Abc::kTop ); MyReader reader( topObj ); OBJ::ParseOBJ( reader, argv[1] ); } catch ( std::exception &exc ) { std::cerr << "EXCEPTION: " << exc.what() << std::endl; exit( -1 ); } return 0; } alembic-1.8.9/examples/CMakeLists.txt000066400000000000000000000040021507001531700174760ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2016, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** # Recurse into libs INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/lib") # No boost dependency was needed so dont include AbcClients IF (USE_PYALEMBIC) ADD_SUBDIRECTORY(AbcClients) ENDIF() alembic-1.8.9/houdini/000077500000000000000000000000001507001531700145635ustar00rootroot00000000000000alembic-1.8.9/houdini/SOP_AlembicIn/000077500000000000000000000000001507001531700171275ustar00rootroot00000000000000alembic-1.8.9/houdini/SOP_AlembicIn/Makefile.hcustom000066400000000000000000000015751507001531700222600ustar00rootroot00000000000000#set these to your alembic check-out and build dirs ABCROOT = ../../lib ABCBUILDROOT = ../../../alembic_build/lib/Alembic INCLUDES = -I $(ABCROOT) LINKPATHS = -L $(ABCBUILDROOT)/Util \ -L $(ABCBUILDROOT)/AbcCoreAbstract \ -L $(ABCBUILDROOT)/AbcCoreOgawa \ -L $(ABCBUILDROOT)/AbcCoreHDF5 \ -L $(ABCBUILDROOT)/Abc \ -L $(ABCBUILDROOT)/AbcCoreFactory \ -L $(ABCBUILDROOT)/AbcGeom LINKS = -l AlembicAbcGeom \ -l AlembicAbcCoreFactory \ -l AlembicAbc \ -l AlembicAbcCoreHDF5 \ -l AlembicAbcCoreOgawa \ -l AlembicAbcCoreAbstract \ -l AlembicUtil \ -l hdf5 -l hdf5_hl HCUSTOM_ADDITIONAL_ARGS = debug: SOP_AlembicIn.C hcustom $(HCUSTOM_ADDITIONAL_ARGS) -e SOP_AlembicIn.C $(INCLUDES) $(LINKPATHS) $(LINKS) rm SOP_AlembicIn.o otl: hotl -b -c OPalembic alembic.otl alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/000077500000000000000000000000001507001531700207625ustar00rootroot00000000000000alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/INDEX__SECTION000066400000000000000000000011721507001531700231000ustar00rootroot00000000000000Operator: alembicxform Label: Alembic Xform Path: oplib:/Object/alembicxform?Object/alembicxform Icon: SOP_alembic Table: Object License: Extra: Inputs: 0 to 0 Subnet: false Python: true Empty: false Modified: Fri Aug 12 12:25:00 2011 Operator: alembicarchive Label: Alembic Archive Path: oplib:/Object/alembicarchive?Object/alembicarchive Icon: SOP_alembic Table: Object License: Extra: Inputs: 0 to 0 Subnet: false Python: true Empty: false Modified: Wed Sep 21 08:42:02 2011 alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicarchive/000077500000000000000000000000001507001531700252675ustar00rootroot00000000000000alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicarchive/CreateScript000066400000000000000000000005561507001531700276100ustar00rootroot00000000000000# Automatically generated script: Wednesday September 21, 08:42 2011 \set noalias = 1 # # Creation script for alembicarchive operator # if ( "$arg1" == "" ) then echo This script is intended as a creation script exit endif # Node $arg1 (Object/alembicarchive) opexprlanguage -s hscript $arg1 opuserdata -n '___Version___' -v '' $arg1 opcf $arg1 opcf .. alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicarchive/DialogScript000066400000000000000000000077051507001531700276070ustar00rootroot00000000000000# Dialog script for alembicarchive automatically generated 09/21/11 08:42:02 { name alembicarchive script alembicarchive label "Alembic Archive" help { "" } group { name "stdswitcher3" label "Transform" invisibletab parm { name "keeppos" baseparm invisible joinnext export none } parm { name "pre_xform" baseparm invisible export none } parm { name "xOrd" baseparm invisible joinnext export none } parm { name "rOrd" baseparm invisible export none } parm { name "t" baseparm invisible export none } parm { name "r" baseparm invisible export none } parm { name "s" baseparm invisible export none } parm { name "p" baseparm invisible export none } parm { name "scale" baseparm invisible export none } parm { name "lookatpath" baseparm invisible export none } parm { name "lookup" baseparm invisible export none } parm { name "pathobjpath" baseparm invisible export none } parm { name "roll" baseparm invisible export none } parm { name "pos" baseparm invisible export none } parm { name "uparmtype" baseparm invisible export none } parm { name "pathorient" baseparm invisible export none } parm { name "up" baseparm invisible export none } parm { name "bank" baseparm invisible export none } } group { name "stdswitcher3_1" label "Subnet" invisibletab parm { name "label1" baseparm invisible export dialog } parm { name "label2" baseparm invisible export dialog } parm { name "label3" baseparm invisible export dialog } parm { name "label4" baseparm invisible export dialog } parm { name "tdisplay" baseparm invisible joinnext export none } parm { name "display" baseparm invisible export none } parm { name "outputobj" baseparm invisible export none } parm { name "visibleobjects" baseparm invisible export none } parm { name "picking" baseparm invisible export none } parm { name "pickscript" baseparm invisible export none } parm { name "caching" baseparm invisible export none } parm { name "use_dcolor" baseparm invisible export none } parm { name "dcolor" baseparm invisible export none } } parm { name "fileName" label "File Name" type file default { "" } range { 0 1 } export none parmtag { "filechooser_mode" "read" } } parm { name "objectPath" label "Object Path" type string default { "" } menureplace { [ "__import__('_alembic_hom_extensions').alembicGetObjectPathListForMenu(hou.pwd().evalParm('fileName'))[:16380]" ] language python } range { 0 1 } export none } parm { name "frame" label "Frame" type float default { "$FF" } range { 0 10 } export none } parm { name "fps" label "Frames Per Second" type float default { "$FPS" } range { 0 10 } export none } multiparm { name "remapAttributes" label "Remap Attributes" parm { name "abcName#" label "Alembic Name #" type string default { "" } range { 0 1 } export none } parm { name "hName#" label "Houdini Name #" type string default { "" } range { 0 1 } export none } } parm { name "buildHierarchy" label "Build or Update Hierarchy" type button default { "1" } range { 0 1 } export none parmtag { "script_callback_language" "python" } parmtag { "script_callback" "kwargs['node'].hdaModule().BuildHierarchyRoot(kwargs['node'])" } parmtag { "export_disable" "1" } } } alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicarchive/ExtraFileOptions000066400000000000000000000001721507001531700304510ustar00rootroot00000000000000PythonModule/IsExprPythonModule/IsPythonPythonModule/IsScriptPythonModule/Sourcealembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicarchive/Help000066400000000000000000000000001507001531700260700ustar00rootroot00000000000000alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicarchive/PythonCook000066400000000000000000000001451507001531700273070ustar00rootroot00000000000000# This code is called when instances of this object cook. # Call hou.pwd().setCookTransform(matrix). alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicarchive/PythonModule000066400000000000000000000076141507001531700276510ustar00rootroot00000000000000 def BuildHierarchyRoot(rootNode): #For now delete the existing children. for child in rootNode.children(): child.destroy() import _alembic_hom_extensions as ABC tree = ABC.alembicGetSceneHierarchy( rootNode.evalParm('fileName'), "") pathList = [x for x in rootNode.evalParm('objectPath').strip('/').split('/') if x] for entry in tree[2]: WalkHierarchy(rootNode, rootNode, '', entry, pathList) _primitiveTypes = frozenset(( 'polymesh', 'subdmesh', 'curves', 'nupatch', 'points', )) def ExpressionToParm(srcParm, dstParm, isString=False): relPath = dstParm.node().relativePathTo(srcParm.node()) dstParm.setExpression('ch%s("%s/%s")' % ( bool(isString)*'s', relPath, srcParm.name())) def WalkHierarchy(rootNode, parentNode, parentPath, childEntry, pathList): name, typeName, children = childEntry if pathList: if pathList[0] != name: return pathList = pathList[1:] currentPath = parentPath + '/' + name if typeName in _primitiveTypes: currentNode = parentNode.createNode('geo') currentNode.setName(name) for child in currentNode.children(): child.destroy() sopNode = currentNode.createNode('alembic') relPath = sopNode.relativePathTo(rootNode) hou.hscript("opmultiparm %s 'abcName#' '%s/abcName#' 'hName#' '%s/hName#'" % ( sopNode.path(), relPath, relPath)) ExpressionToParm(rootNode.parm('remapAttributes'), sopNode.parm('remapAttributes'), isString=True) ExpressionToParm(rootNode.parm('fileName'), sopNode.parm('fileName'), isString=True) ExpressionToParm(rootNode.parm('frame'), sopNode.parm('frame')) ExpressionToParm(rootNode.parm('fps'), sopNode.parm('fps')) sopNode.parm('objectPath').set(currentPath) sopNode.parm('includeXform').set(0) elif typeName == 'xform' or typeName == 'cxform': currentNode = parentNode.createNode('alembicxform') currentNode.setName(name) ExpressionToParm(rootNode.parm('fileName'), currentNode.parm('fileName'), isString=True) if typeName != 'cxform': ExpressionToParm(rootNode.parm('frame'), currentNode.parm('frame')) ExpressionToParm(rootNode.parm('fps'), currentNode.parm('fps')) currentNode.parm('objectPath').set(currentPath) for entry in children: WalkHierarchy(rootNode, currentNode, currentPath, entry, pathList) elif typeName == 'camera': currentNode = parentNode.createNode('cam') currentNode.setName(name) currentNode.addSpareParmTuple(rootNode.parm('fileName').parmTemplate(), ('Alembic',), True) currentNode.addSpareParmTuple(rootNode.parm('frame').parmTemplate(), ('Alembic',), True) currentNode.addSpareParmTuple(rootNode.parm('fps').parmTemplate(), ('Alembic',), True) ExpressionToParm(rootNode.parm('fileName'), currentNode.parm('fileName'), isString=True) ExpressionToParm(rootNode.parm('frame'), currentNode.parm('frame')) ExpressionToParm(rootNode.parm('fps'), currentNode.parm('fps')) for parmName in ( 'focal', 'near', 'far', 'focus', 'winx', 'winy', 'winsizex', 'winsizey', 'aperture'): currentNode.parm(parmName).setExpression( 'pwd().alembicGetCameraDict(ch("fileName"), "%s", ch("frame")/ch("fps")).get("%s")' % ( currentPath, parmName), hou.exprLanguage.Python) else: return def GetObjectMenu(): return ['b', 'b', 'c', 'c'] alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicarchive/Sections.list000066400000000000000000000003271507001531700277550ustar00rootroot00000000000000"" DialogScript DialogScript PythonCook PythonCook TypePropertiesOptions TypePropertiesOptions Help Help Tools.shelf Tools.shelf CreateScript CreateScript PythonModule PythonModule ExtraFileOptions ExtraFileOptions alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicarchive/Tools.shelf000066400000000000000000000015561507001531700274210ustar00rootroot00000000000000 OBJ OBJ $HDA_TABLE/$HDA_NAME Geometry alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicarchive/TypePropertiesOptions000066400000000000000000000004011507001531700315570ustar00rootroot00000000000000ParmsFromVfl := 0; PrefixDroppedParmName := 1; UseDSParms := 1; ForbidOutsideParms := 1; LockContents := 0; SaveSpareParms := 0; CheckExternal := 1; GzipContents := 1; MakeDefault := 1; SaveCachedCode := 0; PrefixDroppedParmLabel := 1; UnlockOnCreate := 0; alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/000077500000000000000000000000001507001531700250015ustar00rootroot00000000000000alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/CreateScript000066400000000000000000000005441507001531700273170ustar00rootroot00000000000000# Automatically generated script: Friday August 12, 12:25 2011 \set noalias = 1 # # Creation script for alembicxform operator # if ( "$arg1" == "" ) then echo This script is intended as a creation script exit endif # Node $arg1 (Object/alembicxform) opexprlanguage -s hscript $arg1 opuserdata -n '___Version___' -v '' $arg1 opcf $arg1 opcf .. alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/DialogScript000066400000000000000000000064111507001531700273120ustar00rootroot00000000000000# Dialog script for alembicxform automatically generated 08/12/11 12:25:00 { name alembicxform script alembicxform label "Alembic Xform" help { "" } group { name "stdswitcher3" label "Transform" invisibletab parm { name "keeppos" baseparm invisible joinnext export none } parm { name "pre_xform" baseparm invisible export none } parm { name "xOrd" baseparm invisible joinnext export none } parm { name "rOrd" baseparm invisible export none } parm { name "t" baseparm invisible export none } parm { name "r" baseparm invisible export none } parm { name "s" baseparm invisible export none } parm { name "p" baseparm invisible export none } parm { name "scale" baseparm invisible export none } parm { name "lookatpath" baseparm invisible export none } parm { name "lookup" baseparm invisible export none } parm { name "pathobjpath" baseparm invisible export none } parm { name "roll" baseparm invisible export none } parm { name "pos" baseparm invisible export none } parm { name "uparmtype" baseparm invisible export none } parm { name "pathorient" baseparm invisible export none } parm { name "up" baseparm invisible export none } parm { name "bank" baseparm invisible export none } } group { name "stdswitcher3_1" label "Subnet" invisibletab parm { name "label1" baseparm invisible export dialog } parm { name "label2" baseparm invisible export dialog } parm { name "label3" baseparm invisible export dialog } parm { name "label4" baseparm invisible export dialog } parm { name "tdisplay" baseparm invisible joinnext export none } parm { name "display" baseparm invisible export none } parm { name "outputobj" baseparm invisible export none } parm { name "visibleobjects" baseparm invisible export none } parm { name "picking" baseparm invisible export none } parm { name "pickscript" baseparm invisible export none } parm { name "caching" baseparm invisible export none } parm { name "use_dcolor" baseparm invisible export none } parm { name "dcolor" baseparm invisible export none } } parm { name "fileName" label "File Name" type file default { "" } range { 0 1 } export none } parm { name "objectPath" label "Object Path" type string default { "" } menureplace { [ "__import__('_alembic_hom_extensions').alembicGetObjectPathListForMenu(hou.pwd().evalParm('fileName'))[:16380]" ] language python } range { 0 1 } export none } parm { name "frame" label "Frame" type float default { 1 } range { 0 10 } export none } parm { name "fps" label "Frames Per Second" type float default { "$FPS" } range { 0 10 } export none } } alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/ExtraFileOptions000066400000000000000000000005361507001531700301670ustar00rootroot00000000000000 OnDeleted/IsExprOnDeleted/IsPythonOnDeleted/IsScriptOnDeleted/SourceOnNameChanged/IsExprOnNameChanged/IsPythonOnNameChanged/IsScriptOnNameChanged/SourcePythonModule/IsExprPythonModule/IsPythonPythonModule/IsScriptPythonModule/Sourcealembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/Help000066400000000000000000000000001507001531700256020ustar00rootroot00000000000000alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/OnDeleted000066400000000000000000000001211507001531700265610ustar00rootroot00000000000000node = kwargs.get('node') if node: node.hdaModule().ResetConstantXform(node) alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/OnNameChanged000066400000000000000000000001261507001531700273520ustar00rootroot00000000000000node = kwargs['node'] node.hdaModule().RenameConstantXform(node, kwargs['old_name']) alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/PythonCook000066400000000000000000000013521507001531700270220ustar00rootroot00000000000000# This code is called when instances of this object cook. import _alembic_hom_extensions as _ahe self = hou.pwd() abcPath = self.evalParm('fileName') objPath = self.evalParm('objectPath') cacheKey = '%s@%s' % (abcPath, objPath) cacheTuple = self.hdaModule().GetConstantXform(self) if isinstance(cacheTuple, tuple) and cacheTuple[0] == cacheKey: hou.pwd().setCookTransform(cacheTuple[1]) else: frameParm = self.parm('frame') fpsParm = self.parm('fps') sampleTime = frameParm.eval() / fpsParm.eval() xform, isConstant = _ahe.alembicGetLocalXform(abcPath, objPath, sampleTime) m = hou.Matrix4(xform) hou.pwd().setCookTransform(m) if isConstant: self.hdaModule().SetConstantXform(self, (cacheKey, m)) alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/PythonModule000066400000000000000000000010311507001531700273460ustar00rootroot00000000000000ConstantXforms = {} def GetConstantXform(node): return ConstantXforms.get(node.path()) def SetConstantXform(node, entry): ConstantXforms[node.path()] = entry def ResetConstantXform(node): path = node.path() if path in ConstantXforms: del ConstantXforms[path] def RenameConstantXform(node, oldName): newPath = node.path() oldPath = newPath.rsplit('/', 1)[0] + '/' + oldName if oldPath in ConstantXforms: ConstantXforms[newPath] = ConstantXforms[oldPath] del ConstantXforms[oldPath] alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/Sections.list000066400000000000000000000004071507001531700274660ustar00rootroot00000000000000"" DialogScript DialogScript PythonCook PythonCook TypePropertiesOptions TypePropertiesOptions Help Help Tools.shelf Tools.shelf CreateScript CreateScript OnNameChanged OnNameChanged OnDeleted OnDeleted PythonModule PythonModule ExtraFileOptions ExtraFileOptions alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/Tools.shelf000066400000000000000000000015561507001531700271330ustar00rootroot00000000000000 OBJ OBJ $HDA_TABLE/$HDA_NAME Geometry alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Object_1alembicxform/TypePropertiesOptions000066400000000000000000000004011507001531700312710ustar00rootroot00000000000000ParmsFromVfl := 0; PrefixDroppedParmName := 1; UseDSParms := 1; ForbidOutsideParms := 1; LockContents := 0; SaveSpareParms := 0; CheckExternal := 1; GzipContents := 1; MakeDefault := 1; SaveCachedCode := 0; PrefixDroppedParmLabel := 1; UnlockOnCreate := 0; alembic-1.8.9/houdini/SOP_AlembicIn/OPalembic/Sections.list000066400000000000000000000001661507001531700234510ustar00rootroot00000000000000"" INDEX__SECTION INDEX_SECTION Object_1alembicxform Object/alembicxform Object_1alembicarchive Object/alembicarchive alembic-1.8.9/houdini/SOP_AlembicIn/README000066400000000000000000000075731507001531700200230ustar00rootroot00000000000000-------------------------------------------------------------------------------- OVERVIEW The reference implementation for reading Alembic data into Houdini contains three nodes: 1) A SOP named Alembic_In 2) A python object node named "Alembic Archive" 3) A python object node named "Alembic Xform" The Alembic_In SOP can read an entire Alembic archive or a subtree of an Alembic archive with the option of baking in transformations. As such, it can serve as the leaf node for geometric primitives while recreating the transformation hierarchy as Houdini objects. It supports loading arbitrary geometry parameters (AbcGeom::GeomParams) as attributes and provides options to remap attribute names on load. The SOP recognizes when data or topology is constant in order to do as little work as necessary upon frame changes. The "Alembic Archive" node constructs and contains the hierarchy of object, SOP and camera nodes used to represent an Alembic scene. Its "Build or Update Hierachy" button reads the archive hierarchy (or specified subtree) and expressions the matching parameters of its internal nodes for convenience. The "Alembic Xform" node queries the local transformation for a specified path within an archive during its cook. It recognizes and caches when transformations are not animated in order to do as little work as necessary on frame changes. -------------------------------------------------------------------------------- AVAILABLE PYTHON FUNCTIONS Both "Alembic Archive" and "Alembic Xform" are dependent upon python functions made available by the Alembic_In SOP. These functions may be of use for other pipeline integration tools. They are available by importing the "_alembic_hom_extensions" module. Here is a quick summary of each: 1) alembicGetLocalXform(archiveFilePath, objectPath, alembicSampleTime) This returns a tuple in this form: (tupleOf16FloatsFor4x4Matrix, boolIsConstant) The second value lets you know whether there is any animated transformation within the archive at that level. 2) alembicGetSceneHierarchy(archiveFilePath, subtreePath) This returns a tuple of values in this form: (name, typeString, tupleOfChildrenInThisForm) This allows you to query the structure of the scene without loading any sampled data. 3) alembicClearArchiveCache() The SOP maintains a cache of Alembic archive handles to avoid reopening the file during multiple cooks across different nodes. 4) alembicSetArchiveMaxCacheSize( maxArchiveHandles ) This allows you to configure the maximum number of archive handles kept open by the SOP at any time. When this limit is exceeded, it will discard handles at random to maintain the limit. 5) alembicGetArchiveMaxCacheSize() Returns the maximum number of archive handles kept open. The default value is currently 50. 6) alembicGetCameraDict(archiveFilePath, cameraPath, alembicSampleTime) This returns a dictionary containing keys matching the relevant "View" parameters on the houdini Camera node. Conversion from Alembic's representation to houdini's representation is done within the function. -------------------------------------------------------------------------------- BUILDING: Due to the use of hcustom, the SOP is not yet integrated into Alembic's CMake setup. Makefile.hcustom has targets for building the SOP and compressing the OPalembic directory into an OTL defining the "Alembic Archive" and "Alemic Xform" nodes. -------------------------------------------------------------------------------- TASKS LEFT TO DO: 1) Of the geometric primitives, only AbcGeom::IPolyMesh and AbcGeom::ISubD mesh are currently supported. AbcGeom::INuPatch, AbcGeom::ICurves and AbcGeom::IPoints remain to be implemented. 2) Overscan and 2D translation of the camera filmback are not yet fully represented. There's enough information available for this, it's just not fully implemented yet. 3) Subdivision surface creases, corners and holes are not yet represented. alembic-1.8.9/houdini/SOP_AlembicIn/SOP_AlembicIn.C000066400000000000000000002647431507001531700216170ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** // Used for internal python bindings #include // This file contains functions that will run arbitrary Python code #include #include "SOP_AlembicIn.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //-***************************************************************************** namespace { void TokenizeObjectPath(const std::string & objectPath, SOP_AlembicIn::PathList & pathList) { typedef hboost::char_separator Separator; typedef hboost::tokenizer Tokenizer; Tokenizer tokenizer( objectPath, Separator( "/" ) ); for ( Tokenizer::iterator iter = tokenizer.begin() ; iter != tokenizer.end() ; ++iter ) { if ( (*iter).empty() ) { continue; } pathList.push_back( *iter ); } } class ArchiveObjectKey : public UT_CappedKey { public: ArchiveObjectKey(const char *key) : UT_CappedKey() , myKey(UT_String::ALWAYS_DEEP, key) { } virtual ~ArchiveObjectKey() {} virtual UT_CappedKey *duplicate() const { return new ArchiveObjectKey(myKey); } virtual unsigned int getHash() const { return myKey.hash(); } virtual bool isEqual(const UT_CappedKey &cmp) const { UT_ASSERT(dynamic_cast(&cmp)); const ArchiveObjectKey *key = static_cast(&cmp); return myKey == key->myKey; } private: UT_String myKey; }; class ArchiveObjectItem : public UT_CappedItem { public: ArchiveObjectItem() : UT_CappedItem() , myIObject() { } ArchiveObjectItem(const IObject &obj) : UT_CappedItem() , myIObject(obj) { } // Approximate usage virtual int64 getMemoryUsage() const { return 1024; } IObject getObject() const { return myIObject; } private: IObject myIObject; }; struct ArchiveCacheEntry { ArchiveCacheEntry() : objectPathMenuList(NULL) , myCache("abcObjects", 2) { } ~ArchiveCacheEntry() { if (objectPathMenuList != NULL) { PY_Py_DECREF(objectPathMenuList); } } // Build a cache of constant transforms void buildTransformCache(IObject root, const char *path) { UT_WorkBuffer fullpath; for (size_t i = 0; i < root.getNumChildren(); ++i) { const ObjectHeader &ohead = root.getChildHeader(i); if (IXform::matches(ohead)) { IXform xform(root, ohead.getName()); IXformSchema &xs = xform.getSchema(); fullpath.sprintf("%s/%s", path, ohead.getName().c_str()); if (xs.isConstant()) { XformSample xsample = xs.getValue(ISampleSelector(0.0)); myTransforms[fullpath.buffer()] = xsample.getMatrix(); } buildTransformCache(xform, fullpath.buffer()); } } } bool findTransform(const char *fullpath, M44d &xform) { if (myTransforms.size() == 0) { IObject root = archive.getTop(); buildTransformCache(root, ""); //fprintf(stderr, "%d transforms\n", (int)myTransforms.size()); } std::map::const_iterator it; it = myTransforms.find(fullpath); if (it != myTransforms.end()) { xform = it->second; return true; } return false; } IObject findObject(IObject parent, UT_WorkBuffer &fullpath, const char *component) { fullpath.append("/"); fullpath.append(component); ArchiveObjectKey key(fullpath.buffer()); IObject kid; UT_CappedItemHandle item = myCache.findItem(key); if (item) { kid = static_cast(item.get())->getObject(); } else { kid = parent.getChild(component); if (kid.valid()) myCache.addItem(key, new ArchiveObjectItem(kid)); } return kid; } IObject getObject(const std::string &objectPath) { SOP_AlembicIn::PathList pathList; IObject curr = archive.getTop(); UT_WorkBuffer fullpath; TokenizeObjectPath(objectPath, pathList); for (SOP_AlembicIn::PathList::const_iterator I = pathList.begin(); I != pathList.end() && curr.valid(); ++I) { curr = findObject(curr, fullpath, (*I).c_str()); } return curr; } Abc::IArchive archive; std::string error; PY_PyObject * objectPathMenuList; std::map myTransforms; UT_CappedCache myCache; }; typedef hboost::shared_ptr ArchiveCacheEntryRcPtr; typedef std::map, ArchiveCacheEntryRcPtr> ArchiveCache; //-************************************************************************* size_t g_maxCache = 50; //for now, leak the pointer to the archive cache so we don't //crash at shutdown ArchiveCache * g_archiveCache(new ArchiveCache); //-************************************************************************* ArchiveCacheEntryRcPtr LoadArchive(const std::vector & paths) { ArchiveCache::iterator I = g_archiveCache->find(paths); if (I != g_archiveCache->end()) { return (*I).second; } ArchiveCacheEntryRcPtr entry = ArchiveCacheEntryRcPtr( new ArchiveCacheEntry); try { ::Alembic::AbcCoreFactory::IFactory factory; entry->archive = factory.getArchive( paths ); } catch (const std::exception & e) { entry->error = e.what(); } while (g_archiveCache->size() >= g_maxCache) { long d = static_cast(std::floor( static_cast(std::rand()) / RAND_MAX * g_maxCache - 0.5)); if (d < 0) { d = 0; } ArchiveCache::iterator it = g_archiveCache->begin(); for (; d > 0; --d) { ++it; } g_archiveCache->erase(it); } (*g_archiveCache)[paths] = entry; return entry; } void ClearArchiveFile(const std::vector &paths) { ArchiveCache::iterator it = g_archiveCache->find(paths); if (it != g_archiveCache->end()) g_archiveCache->erase(it); } void ClearArchiveCache() { delete g_archiveCache; g_archiveCache = new ArchiveCache; } //-************************************************************************** std::string filenamesToString(const std::vector &filenames) { UT_WorkBuffer buffer; for (int i = 0; i < filenames.size(); ++i) { if(i) buffer.append(", "); buffer.append(filenames[i].c_str()); } return buffer.toStdString(); } } void SOP_AlembicIn::clearCacheFile(const std::vector *filenames) { if (filenames) ClearArchiveFile(*filenames); else ClearArchiveCache(); } void SOP_AlembicIn::appendFileNames(std::vector &filenames, fpreal t) { int numlayers = evalInt("numlayers", 0, t); for (int i = 1; i <= numlayers; ++i) { if (evalIntInst("enablelayer#", &i, 0, t)) { UT_String fileName; evalStringInst("layer#", &i, fileName, 0, t); if (fileName.isstring()) filenames.push_back(fileName.toStdString()); } } UT_String name; evalString(name, "fileName", 0, t); if(name.isstring()) filenames.push_back(name.toStdString()); } // Class to help us walk the tree // // The sop_IAlembicWalker class needs to be in a public namespace for forward // declarations. class sop_IAlembicWalker { public: sop_IAlembicWalker(ArchiveCacheEntry &arch) : myArchive(arch) , myPathBuffer() { } IObject nextObject(IObject parent, const std::string &component) { return myArchive.findObject(parent, myPathBuffer, component.c_str()); } private: ArchiveCacheEntry &myArchive; UT_WorkBuffer myPathBuffer; }; //-***************************************************************************** OP_Node * SOP_AlembicIn::myConstructor( OP_Network *net, const char *name, OP_Operator *op) { return new SOP_AlembicIn( net, name, op ); } //-***************************************************************************** static PRM_Name prm_abcAttribName("abcName#", "Alembic Name #"); static PRM_Name prm_hAttribName("hName#", "Houdini Name #"); static PRM_Template prm_AttributeRemapTemplate[] = { PRM_Template(PRM_STRING, 1, &prm_abcAttribName), PRM_Template(PRM_STRING, 1, &prm_hAttribName), PRM_Template() }; static PRM_Name prm_fileNameName("fileName", "File Name"); static PRM_Name prm_numlayersName("numlayers", "Number of Layers"); static PRM_Name prm_frameName("frame", "Frame"); static PRM_Name prm_fpsName("fps", "Frames Per Second"); static PRM_Name prm_objectPathName("objectPath", "Object Path"); static PRM_Name prm_includeXformName("includeXform", "Include Xform"); static PRM_Name prm_remapAttribName("remapAttributes", "Remap Attributes"); static PRM_Default prm_frameDefault(1, "$FF"); static PRM_Default prm_objectPathDefault(0, ""); static PRM_Default prm_fpsDefault(24, "$FPS"); static PRM_Default prm_includeXformDefault(true); static PRM_ChoiceList prm_objectPathMenu(PRM_CHOICELIST_TOGGLE, "def getFileName(node):\n" " r = []\n" " for i in range(node.evalParm('numlayers')):\n" " if node.evalParm('enablelayer%d' % (i + 1,)):\n" " p = node.evalParm('layer%d' % (i + 1,))\n" " if p:\n" " r.append(p)\n" " p = node.evalParm('fileName')\n" " if p:\n" " r.append(p)\n" " return r\n" "return __import__('_alembic_hom_extensions').alembicGetObjectPathListForMenu" "(getFileName(hou.pwd()))[:16380]", CH_PYTHON_SCRIPT); // As of 16.5, Houdini has a limit of 16380 items in a UI menu, so we // limit the list length to be safe static PRM_Name prm_enablelayerName("enablelayer#", ""); static PRM_Name prm_layerName("layer#", "Layer #"); static PRM_Template prm_layersTemplate[] = { PRM_Template(PRM_TOGGLE, PRM_TYPE_TOGGLE_JOIN, 1, &prm_enablelayerName, PRMoneDefaults), PRM_Template(PRM_FILE, 1, &prm_layerName), PRM_Template() }; PRM_Template SOP_AlembicIn::myTemplateList[] = { PRM_Template(PRM_FILE, 1, &prm_fileNameName), PRM_Template(PRM_MULTITYPE_LIST, prm_layersTemplate, 1, &prm_numlayersName, 0, 0, &PRM_SpareData::multiStartOffsetOne), PRM_Template(PRM_FLT_J, 1, &prm_frameName, &prm_frameDefault), PRM_Template(PRM_FLT_J, 1, &prm_fpsName, &prm_fpsDefault), PRM_Template(PRM_STRING, 1, &prm_objectPathName, &prm_objectPathDefault, &prm_objectPathMenu), PRM_Template(PRM_TOGGLE, 1, &prm_includeXformName, &prm_includeXformDefault), PRM_Template(PRM_MULTITYPE_LIST, prm_AttributeRemapTemplate, 2, &prm_remapAttribName, PRMzeroDefaults, 0, &PRM_SpareData::multiStartOffsetOne), PRM_Template() }; //-***************************************************************************** SOP_AlembicIn::SOP_AlembicIn(OP_Network *net, const char *name, OP_Operator *op) : SOP_Node(net, name, op) , myFileObjectCache(UT_String::ALWAYS_DEEP, "") , myTopologyConstant(false) , myEntireSceneIsConstant(false) , myConstantUniqueId(-1) , myConstantPointCount(0) , myConstantPrimitiveCount(0) { } //-***************************************************************************** SOP_AlembicIn::~SOP_AlembicIn() { } //-***************************************************************************** bool SOP_AlembicIn::unloadData() { bool unloaded = SOP_Node::unloadData(); if (unloaded) { } return unloaded; } //-***************************************************************************** OP_ERROR SOP_AlembicIn::cookMySop(OP_Context &context) { Args args; std::map nameMap; bool sop_flushed = false; const float now = context.getTime(); args.includeXform = evalInt("includeXform", 0, now); if (gdp->getUniqueId() != myConstantUniqueId || gdp->getNumPoints() != myConstantPointCount || gdp->getNumPrimitives() != myConstantPrimitiveCount) { // When the SOP cache flushes my geometry, make sure to recreate // primitives etc. // This may also happen if the geometry is instanced by time shift or // by DOPs. sop_flushed = true; } std::vector fileNames; appendFileNames(fileNames, now); PathList pathList; std::string objectPath; { UT_String str; evalString(str, "objectPath", 0, now); objectPath = str.toStdString(); } // If the file or object parameter has changed, we need to reset our // primitive cache. UT_WorkBuffer fileobjecthash; fileobjecthash.sprintf("%s:%s:%d", filenamesToString(fileNames).c_str(), objectPath.c_str(), args.includeXform); int nmapSize = evalInt("remapAttributes", 0, now); // Entries are one based (not zero based) for (int i = 1; i <= nmapSize; ++i) { UT_String abcName, hName; evalStringInst("abcName#", &i, abcName, 0, now); evalStringInst("hName#", &i, hName, 0, now); if (abcName.isstring() && hName.isstring()) { nameMap[abcName.toStdString()] = hName.toStdString(); // Incorporate attribute remapping values into the fileobjecthash // so that recooks reflect the new state even for constant data fileobjecthash.sprintf(":%s->%s", (const char *)abcName, (const char *)hName); } } if (sop_flushed || strcmp(myFileObjectCache, fileobjecthash.buffer()) != 0) { myFileObjectCache.harden(fileobjecthash.buffer()); myTopologyConstant = false; myEntireSceneIsConstant = false; myPrimitiveCountCache.clear(); } // Exit early if the entire scene (within this SOP) was recognized // as constant on a previous cook. Note that we haven't yet evaluated // the "frame" parm so we won't be called for subsequent cooks. if (myEntireSceneIsConstant) { return error(); } if ( !objectPath.empty() ) { TokenizeObjectPath(objectPath, pathList); } M44d xform; if (!myTopologyConstant) { // std::cerr<<"clearing geo\n"; gdp->clearAndDestroy(); } else { gdp->destroyInternalNormalAttribute(); } double fps = evalFloat("fps", 0, now); args.abcTime = evalFloat("frame", 0, now) / fps; args.isConstant = true; args.isTopologyConstant = true; args.reusePrimitives = myTopologyConstant && gdp->getNumPrimitives()>0; args.pointCount = 0; args.primCount = 0; args.nameMap = &nameMap; args.boss = UTgetInterrupt(); args.activePatchRows = 0; args.activePatchCols = 0; if (!args.boss->opStart("Loading and walking Alembic data")) { args.boss->opEnd(); return error(); } if (fileNames.empty()) { args.boss->opEnd(); addWarning(SOP_MESSAGE, "No files specified."); return error(); } try { ArchiveCacheEntryRcPtr cacheEntry = LoadArchive(fileNames); if (!cacheEntry->archive.valid() ) { std::ostringstream buffer; buffer << "Alembic exception: "; buffer << cacheEntry->error; addWarning(SOP_MESSAGE, buffer.str().c_str()); args.boss->opEnd(); return error(); } attachDetailStringData("abcFileName", filenamesToString(fileNames)); IObject root = cacheEntry->archive.getTop(); if ( pathList.empty() ) //walk the entire scene { sop_IAlembicWalker walker(*cacheEntry); for ( size_t i = 0; i < root.getNumChildren(); ++i ) { walkObject( args, walker, root, root.getChildHeader(i), pathList.end(), pathList.end(), xform, true); } } else //walk to a location + its children { sop_IAlembicWalker walker(*cacheEntry); PathList::const_iterator I = pathList.begin(); const ObjectHeader *nextChildHeader = root.getChildHeader( *I ); if ( nextChildHeader != NULL ) { walkObject( args, walker, root, *nextChildHeader, I+1, pathList.end(), xform, true); } } // If after doing our traversal nothing has changed args.isConstant, // then we copy that state back to our member variables. if (args.isConstant) { myEntireSceneIsConstant = true; } myTopologyConstant = args.isTopologyConstant; } catch ( const InterruptedException & /*e*/ ) { //currently thrown by WalkObject myEntireSceneIsConstant = false; myTopologyConstant = false; myPrimitiveCountCache.clear(); } catch ( const std::exception &e ) { std::ostringstream buffer; buffer << "Alembic exception: "; buffer << e.what(); addWarning(SOP_MESSAGE, buffer.str().c_str()); } if (myTopologyConstant) { myConstantPointCount = gdp->getNumPoints(); myConstantPrimitiveCount = gdp->getNumPrimitives(); myConstantUniqueId = gdp->getUniqueId(); } args.boss->opEnd(); return error(); } //-***************************************************************************** void SOP_AlembicIn::nodeUnlocked() { } //-***************************************************************************** static GA_RWAttributeRef findStringTuple(GU_Detail &gdp, GA_AttributeOwner owner, const char *name, int min_size=1) { return gdp.findStringTuple(owner, name, min_size); } static GA_RWAttributeRef addStringTuple(GU_Detail &gdp, GA_AttributeOwner owner, const char *name, int size) { return gdp.addStringTuple(owner, name, size); } static GA_RWAttributeRef findIntTuple(GU_Detail &gdp, GA_AttributeOwner owner, const char *name, int min_size) { return gdp.findIntTuple(owner, name, min_size); } static GA_RWAttributeRef addIntTuple(GU_Detail &gdp, GA_AttributeOwner owner, const char *name, int size) { return gdp.addIntTuple(owner, name, size); } static GA_RWAttributeRef addInt64Tuple(GU_Detail &gdp, GA_AttributeOwner owner, const char *name, int size) { return gdp.addIntTuple(owner, name, size, GA_Defaults(0), NULL, NULL, GA_STORE_INT64); } static GA_RWAttributeRef findFloatTuple(GU_Detail &gdp, GA_AttributeOwner owner, const char *name, int min_size) { return gdp.findFloatTuple(owner, name, min_size); } static GA_RWAttributeRef addFloatTuple(GU_Detail &gdp, GA_AttributeOwner owner, const char *name, int size, bool normal) { GA_RWAttributeRef h = gdp.addFloatTuple(owner, name, size); if (h.isValid() && normal) { h.getAttribute()->setTypeInfo(GA_TYPE_NORMAL); } return h; } static GA_RWAttributeRef addVelocity(GU_Detail &gdp, GA_AttributeOwner owner) { return gdp.addVelocityAttribute(owner); } static void setTypeInfo(GA_RWAttributeRef &aref, GA_TypeInfo tinfo) { if (aref.isValid() && tinfo != GA_TYPE_VOID) { aref.getAttribute()->setTypeInfo(tinfo); } } static void addToGroup(GA_PrimitiveGroup *group, GEO_Primitive *gb) { group->add(gb); } GA_ROAttributeRef SOP_AlembicIn::attachDetailStringData( const std::string &attrName, const std::string &value) { GA_RWAttributeRef attr = findStringTuple(*gdp, GA_ATTRIB_DETAIL, attrName.c_str()); if (attr.isInvalid()) { attr = addStringTuple(*gdp, GA_ATTRIB_DETAIL, attrName.c_str(), 1); if (error() >= UT_ERROR_ABORT || attr.isInvalid()) { std::ostringstream buffer; buffer << "Could not create detail string attribute: "; buffer << attrName; addWarning(SOP_MESSAGE, buffer.str().c_str()); } } const GA_AIFStringTuple *aifstring = attr.getAIFStringTuple(); if (aifstring) { aifstring->setString(attr.getAttribute(), GA_Offset(0), value.c_str(), 0); } else { return GA_ROAttributeRef(); } return attr; } //-***************************************************************************** void SOP_AlembicIn::walkObject( Args & args, sop_IAlembicWalker &walker, IObject parent, const ObjectHeader &ohead, PathList::const_iterator I, PathList::const_iterator E, M44d parentXform, bool parentXformIsConstant) { if ( args.boss->opInterrupt() ) { throw InterruptedException( parent.getFullName() + ohead.getName() ); } //set this if we should continue traversing IObject nextParentObject; if ( IXform::matches( ohead ) ) { if (args.includeXform) { IXform xform( parent, ohead.getName() ); IXformSchema &xs = xform.getSchema(); if (!xs.isConstant()) { args.isConstant = false; parentXformIsConstant = false; } XformSample xformSample = xs.getValue( ISampleSelector( args.abcTime )); M44d m = xformSample.getMatrix(); if (xformSample.getInheritsXforms()) { parentXform = m * parentXform; } else { parentXform = m; } nextParentObject = xform; } else { //if we're not processing transforms, just grab the child object //and move on nextParentObject = walker.nextObject(parent, ohead.getName()); } } else if ( ISubD::matches( ohead ) ) { ISubD subd( parent, ohead.getName() ); ISubDSchema &ss = subd.getSchema(); if (ss.getTopologyVariance() == kHeterogenousTopology) { args.isTopologyConstant = false; } buildSubD( args, subd, parentXform, parentXformIsConstant ); nextParentObject = subd; } else if ( IPolyMesh::matches( ohead ) ) { IPolyMesh polymesh( parent, ohead.getName() ); IPolyMeshSchema &ps = polymesh.getSchema(); if (ps.getTopologyVariance() == kHeterogenousTopology) { args.isTopologyConstant = false; } buildPolyMesh( args, polymesh, parentXform, parentXformIsConstant ); nextParentObject = polymesh; } else if ( ICurves::matches( ohead) ) { ICurves curves(parent, ohead.getName()); ICurvesSchema &cs = curves.getSchema(); if (cs.getTopologyVariance() == kHeterogenousTopology) { args.isTopologyConstant = false; } buildCurves( args, curves, parentXform, parentXformIsConstant ); nextParentObject = curves; } else if ( IPoints::matches( ohead) ) { IPoints points(parent, ohead.getName()); IPointsSchema &ps = points.getSchema(); if (!ps.isConstant()) { args.isTopologyConstant = false; } buildPoints( args, points, parentXform, parentXformIsConstant ); nextParentObject = points; } else if ( INuPatch::matches( ohead ) ) { INuPatch nupatch( parent, ohead.getName() ); if ( nupatch.getSchema().getTopologyVariance() == kHeterogenousTopology ) { args.isTopologyConstant = false; } buildNuPatch( args, nupatch, parentXform, parentXformIsConstant ); nextParentObject = nupatch; } else { //For now, silently skip types we don't recognize } if ( nextParentObject.valid() ) { if ( I == E ) { for ( size_t i = 0; i < nextParentObject.getNumChildren(); ++i ) { walkObject( args, walker, nextParentObject, nextParentObject.getChildHeader( i ), I, E, parentXform, parentXformIsConstant); } } else { const ObjectHeader *nextChildHeader = nextParentObject.getChildHeader( *I ); if ( nextChildHeader != NULL ) { walkObject( args, walker, nextParentObject, *nextChildHeader, I+1, E, parentXform, parentXformIsConstant); } } } } //-***************************************************************************** static std::string fixAttributeName(const std::string &name) { // Houdini 12 only allows "variable" style names for group/attribute names // Note that this may cause group collisions with trees like: // - /ABC/foo/bar // - /ABC/foo_bar // - /ABC/foo.bar // since all three paths will be converted to _ABC_foo_bar // // The right thing todo is to maintain a map of groupnames to paths so that // we can export the correct node path. UT_String var(name.c_str()); if (var.forceValidVariableName()) return std::string((const char *)var); return name; } std::string SOP_AlembicIn::getFullName( IObject object ) { std::string result = object.getFullName(); if (result.size() > 4 && result.substr(0, 5) == "/ABC/") { return result.substr( 4, result.size() - 1 ); } return result; } //-***************************************************************************** void SOP_AlembicIn::addUVs(Args & args, IV2fGeomParam param, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs) { if (!param.valid()) { return; } GA_RWAttributeRef uvAttr; switch (param.getScope()) { case kVaryingScope: case kVertexScope: { addOrFindTextureAttribute(GA_ATTRIB_POINT, uvAttr); break; } case kFacevaryingScope: { addOrFindTextureAttribute(GA_ATTRIB_VERTEX, uvAttr); break; } default: break; } if (uvAttr.isValid()) { processArbitraryGeomParam( args, param.getParent(), param.getHeader(), GA_STORE_REAL32, GA_TYPE_VOID, uvAttr, startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } } void SOP_AlembicIn::addWidths(Args & args, IFloatGeomParam param, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs) { if (!param.valid()) { return; } GA_RWAttributeRef widthAttr; switch (param.getScope()) { case kVaryingScope: case kVertexScope: { addOrFindWidthAttribute(GA_ATTRIB_POINT, widthAttr); break; } case kFacevaryingScope: { addOrFindWidthAttribute(GA_ATTRIB_VERTEX, widthAttr); break; } default: break; } if (widthAttr.isValid()) { processArbitraryGeomParam( args, param.getParent(), param.getHeader(), GA_STORE_REAL32, GA_TYPE_VOID, widthAttr, startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } } //-***************************************************************************** void SOP_AlembicIn::addNormals(Args & args, IN3fGeomParam param, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs, bool parentXformIsConstant) { if (!param.valid()) { return; } GA_RWAttributeRef nAttr; switch (param.getScope()) { case kVaryingScope: case kVertexScope: { addOrFindNormalAttribute(GA_ATTRIB_POINT, nAttr); break; } case kFacevaryingScope: { addOrFindNormalAttribute(GA_ATTRIB_VERTEX, nAttr); break; } default: break; } if (nAttr.isValid()) { processArbitraryGeomParam( args, param.getParent(), param.getHeader(), GA_STORE_REAL32, GA_TYPE_NORMAL, nAttr, startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); } } //-***************************************************************************** bool SOP_AlembicIn::addOrFindTextureAttribute(GA_AttributeOwner owner, GA_RWAttributeRef & attr) { attr = gdp->findTextureAttribute(owner); if (!attr.isValid()) { attr = gdp->addTextureAttribute(owner); if (error() >= UT_ERROR_ABORT || !attr.isValid()) { addError(SOP_MESSAGE, "could not create texture attribute."); return false; } } return true; } bool SOP_AlembicIn::addOrFindWidthAttribute(GA_AttributeOwner owner, GA_RWAttributeRef & attr) { attr = gdp->addTuple(GA_STORE_REAL32, owner, GA_SCOPE_PUBLIC, "width", 1, GA_Defaults(0.1)); if (error() >= UT_ERROR_ABORT || !attr.isValid()) { addError(SOP_MESSAGE, "could not create width attribute."); return false; } return true; } //-***************************************************************************** bool SOP_AlembicIn::addOrFindNormalAttribute(GA_AttributeOwner owner, GA_RWAttributeRef & attr) { attr = gdp->findNormalAttribute(owner); if (!attr.isValid()) { attr = gdp->addNormalAttribute(owner); if (error() >= UT_ERROR_ABORT || !attr.isValid()) { addError(SOP_MESSAGE, "could not create Normal attribute."); return false; } } return true; } //-***************************************************************************** void SOP_AlembicIn::addArbitraryGeomParams(Args & args, ICompoundProperty parent, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs, bool parentXformIsConstant) { if (!parent.valid()) { return; } for (size_t i = 0; i < parent.getNumProperties(); ++i) { const PropertyHeader &propHeader = parent.getPropertyHeader(i); if (IFloatGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL32, GA_TYPE_VOID, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IHalfGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL16, GA_TYPE_VOID, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IDoubleGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL64, GA_TYPE_VOID, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (ICharGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_INT8, GA_TYPE_VOID, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IInt16GeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_INT16, GA_TYPE_VOID, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IInt32GeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_INT32, GA_TYPE_VOID, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IInt64GeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_INT64, GA_TYPE_VOID, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IStringGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_STRING, GA_TYPE_VOID, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IV2fGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL32, GA_TYPE_VOID, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IV2dGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL64, GA_TYPE_VOID, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IV3fGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL32, GA_TYPE_VECTOR, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); } else if (IV3dGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL64, GA_TYPE_VECTOR, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); } else if (IN3fGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL32, GA_TYPE_NORMAL, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); } else if (IN3dGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL64, GA_TYPE_NORMAL, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); } else if (IC3hGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL16, GA_TYPE_COLOR, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IC3fGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL32, GA_TYPE_COLOR, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IC3cGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_INT8, GA_TYPE_COLOR, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IP3fGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL32, GA_TYPE_POINT, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IP3dGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_REAL64, GA_TYPE_POINT, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } else if (IBoolGeomParam::matches(propHeader)) { processArbitraryGeomParam( args, parent, propHeader, GA_STORE_INT8, GA_TYPE_VOID, GA_RWAttributeRef(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, false); } } } //-***************************************************************************** template void SOP_AlembicIn::processArbitraryGeomParam( Args & args, ICompoundProperty parent, const PropertyHeader & propHeader, GA_Storage attrStorage, GA_TypeInfo attrTypeInfo, const GA_RWAttributeRef & existingAttr, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs, bool parentXformIsConstant ) { GA_RWAttributeRef attr = existingAttr; geomParamT param(parent, propHeader.getName()); // If the param isn't changing and isn't affected by animation in inherited // transformations, exit early if (param.isConstant()) { if (args.reusePrimitives && (!args.includeXform || parentXformIsConstant)) { return; } } ISampleSelector sampleSelector( args.abcTime ); typename geomParamT::sample_type paramSample; param.getExpanded(paramSample, sampleSelector); size_t extent = geomParamT::prop_type::traits_type::dataType().getExtent(); size_t arrayExtent = param.getArrayExtent(); // If it's a standard array property, the number of elements in // the sample's data can be queried from the Dimensions object size_t dimPoints = 1; if (propHeader.isArray()) dimPoints = paramSample.getVals().get()->getDimensions().numPoints(); size_t totalExtent = extent*arrayExtent; GA_AttributeOwner owner = GA_ATTRIB_PRIMITIVE; switch (paramSample.getScope()) { case kVaryingScope: case kVertexScope: // TODO: For NURBS, kVertexScope should use GA_ATTRIB_VERTEX owner = GA_ATTRIB_POINT; break; case kFacevaryingScope: owner = GA_ATTRIB_VERTEX; break; case kConstantScope: case kUnknownScope: // constant (and unknown) properties don't iterate over the // array data, so the whole data needs to get stored in the // primitive totalExtent *= dimPoints; case kUniformScope: owner = GA_ATTRIB_PRIMITIVE; } if (!attr.isValid()) { std::string aname = propHeader.getName(); std::map::const_iterator it = args.nameMap->find(aname); if (it != args.nameMap->end()) { aname = it->second; } if (GAisIntStorage(attrStorage)) { attr = findIntTuple(*gdp, owner, aname.c_str(), totalExtent); if (!attr.isValid()) { attr = addIntTuple(*gdp, owner, aname.c_str(), totalExtent); } } else if (GAisFloatStorage(attrStorage)) { attr = findFloatTuple(*gdp, owner, aname.c_str(), totalExtent); if (!attr.isValid()) { attr = addFloatTuple(*gdp, owner, aname.c_str(), totalExtent, attrTypeInfo == GA_TYPE_NORMAL); } } else { UT_ASSERT(attrStorage == GA_STORE_STRING); attr = findStringTuple(*gdp, owner, aname.c_str(), totalExtent); if (!attr.isValid()) { attr = addStringTuple(*gdp, owner, aname.c_str(), totalExtent); } } } if (!attr.isValid()) { //TODO, indicate as error, for now just skip it return; } setTypeInfo(attr, attrTypeInfo); applyArbitraryGeomParamSample( args, paramSample, attr, totalExtent, startPointOfs, endPointOfs, startPrimOfs, endPrimOfs); } //-***************************************************************************** template void SOP_AlembicIn::applyArbitraryGeomParamSample( Args & args, geomParamSampleT & paramSample, const GA_RWAttributeRef & attr, size_t totalExtent, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs ) { GA_RWHandleT h(attr.getAttribute()); int tsize = SYSmin((int)totalExtent, attr.getTupleSize()); switch (paramSample.getScope()) { case kUniformScope: { const podT * values =reinterpret_cast( paramSample.getVals()->get()); size_t i = 0; for (GA_Offset primofs = startPrimOfs; primofs < endPrimOfs; ++primofs, ++i) { h.setV(primofs, values+i*totalExtent, tsize); } break; } case kVaryingScope: case kVertexScope: { // TODO, for kVaryingScope on a nupatch, need to interpolate // from the corner values and apply to the points as normal // We'll know if we're a nupatch if args.activePatchRows > 0 // For now, skip it if (args.activePatchRows > 0 && paramSample.getScope() == kVaryingScope ) { return; } const podT * values = reinterpret_cast( paramSample.getVals()->get()); size_t i = 0; for (GA_Offset pt = startPointOfs; pt < endPointOfs; ++pt, ++i) { h.setV(pt, values+i*totalExtent, tsize); } break; } case kFacevaryingScope: { const podT * values = reinterpret_cast( paramSample.getVals()->get()); size_t vertexIdx = 0; for (GA_Offset primOfs = startPrimOfs; primOfs < endPrimOfs; ++primOfs) { GEO_Primitive *prim = gdp->getGEOPrimitive(primOfs); int vtxCount = prim->getVertexCount(); for(int i=0; i < vtxCount; ++i, ++vertexIdx) { h.setV(prim->getVertexOffset(i), values+vertexIdx*totalExtent, tsize); } } break; } case kConstantScope: case kUnknownScope: default: { const podT * values = reinterpret_cast( paramSample.getVals()->get()); for (size_t primofs = startPrimOfs; primofs < endPrimOfs; ++primofs) { h.setV(primofs, values, tsize); } break; } } } //-***************************************************************************** //specialized for handling the string case template <> void SOP_AlembicIn::applyArbitraryGeomParamSample< IStringGeomParam::sample_type, std::string>( Args & args, IStringGeomParam::sample_type & paramSample, const GA_RWAttributeRef & attr, size_t totalExtent, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs ) {//TACO GA_RWHandleS h(attr.getAttribute()); switch (paramSample.getScope()) { case kUniformScope: { const std::string * values =reinterpret_cast( paramSample.getVals()->get()); size_t i = 0; for (GA_Offset primofs = startPrimOfs; primofs < endPrimOfs; ++primofs, ++i) { for (size_t j = 0; j < totalExtent; ++j) { h.set(primofs, j, values[i*totalExtent+j].c_str()); } } break; } case kVaryingScope: case kVertexScope: { const std::string * values = reinterpret_cast( paramSample.getVals()->get()); size_t i = 0; for (GA_Offset pt = startPointOfs; pt < endPointOfs; ++pt, ++i) { for (size_t j = 0; j < totalExtent; ++j) { h.set(pt, j, values[i*totalExtent+j].c_str()); } } break; } case kFacevaryingScope: { const std::string * values = reinterpret_cast( paramSample.getVals()->get()); size_t vertexIdx = 0; for (GA_Offset primofs = startPrimOfs; primofs < endPrimOfs; ++primofs) { GEO_Primitive *prim = gdp->getGEOPrimitive(primofs); int vtxCount = prim->getVertexCount(); for(int i=0; i < vtxCount; ++i, ++vertexIdx) { for (size_t j = 0; j < totalExtent; ++j) { h.set(prim->getVertexOffset(i), j, values[vertexIdx*totalExtent+j].c_str()); } } } break; } case kConstantScope: default: { const std::string * values = reinterpret_cast( paramSample.getVals()->get()); for (GA_Offset primofs = startPrimOfs; primofs < endPrimOfs; ++primofs) { for (size_t j = 0; j < totalExtent; ++j) { h.set(primofs, j, values[j].c_str()); } } break; } } } //-***************************************************************************** bool SOP_AlembicIn::updateParmsFlags() { bool changed = false; int numlayers = evalInt("numlayers", 0, 0); for (int i = 1; i <= numlayers; ++i) changed |= enableParmInst("layer#", &i, evalIntInst("enablelayer#", &i, 0, 0)); return changed; } //-***************************************************************************** void SOP_AlembicIn::buildSubD( Args & args, ISubD &subd, M44d parentXform, bool parentXformIsConstant) { ISampleSelector sampleSelector( args.abcTime ); ISubDSchema &ss = subd.getSchema(); if (!ss.isConstant()) { args.isConstant = false; } // If the schema is constant and we've already cooked once, we can exit // early assuming that we're either not baking in tranforms or the inherited // transformations are constant. else if (args.reusePrimitives) { if (!args.includeXform || parentXformIsConstant) { // Update point/prim counts Abc::P3fArraySamplePtr pSample = ss.getPositionsProperty().getValue(sampleSelector); std::string groupName = fixAttributeName(getFullName(subd)); args.pointCount += pSample->size(); // Add # points args.primCount += myPrimitiveCountCache[groupName]; return; } } //store the primitive and point start indices GA_Offset startPointOfs = args.pointCount; GA_Offset startPrimOfs = args.primCount; GA_PrimitiveGroup * primGrp; if (args.reusePrimitives) { Abc::P3fArraySamplePtr pSample = ss.getPositionsProperty().getValue(sampleSelector); std::string groupName = fixAttributeName(getFullName(subd)); primGrp = reuseMesh(groupName, pSample, startPointOfs); args.pointCount += pSample->size(); // Add # points //always present in myPrimitiveCountCache if args.reusePrimitives args.primCount += myPrimitiveCountCache[groupName]; } else { ISubDSchema::Sample sample = ss.getValue( sampleSelector ); args.pointCount += sample.getPositions()->size(); // Add # points args.primCount += sample.getFaceCounts()->size(); // Add # faces std::string groupName = fixAttributeName(getFullName(subd)); primGrp = buildMesh(groupName, sample.getPositions(), sample.getFaceCounts(), sample.getFaceIndices()); } GA_Offset endPointOfs = args.pointCount; GA_Offset endPrimOfs = args.primCount; addUVs(args, subd.getSchema().getUVsParam(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs); addArbitraryGeomParams(args, subd.getSchema().getArbGeomParams(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); //apply xforms via gdp->transform so that we don't have to think //about normals and other affected attributes if (args.includeXform && parentXform != M44d()) { UT_DMatrix4 dxform(parentXform.x); UT_Matrix4 xform(dxform); gdp->transform(xform, primGrp); } //subd tagging? } //-***************************************************************************** void SOP_AlembicIn::buildPolyMesh( Args & args, IPolyMesh & polymesh, M44d parentXform, bool parentXformIsConstant) { ISampleSelector sampleSelector( args.abcTime ); IPolyMeshSchema &schema = polymesh.getSchema(); if (!schema.isConstant()) { args.isConstant = false; } // If the schema is constant and we've already cooked once, we can exit // early assuming that we're either not baking in tranforms or the inherited // transformations are constant.else if (args.reusePrimitives) else if (args.reusePrimitives) { if (!args.includeXform || parentXformIsConstant) { // Update point/prim counts Abc::P3fArraySamplePtr pSample = schema.getPositionsProperty().getValue(sampleSelector); std::string groupName = fixAttributeName(getFullName(polymesh)); args.pointCount += pSample->size(); // Add # points args.primCount += myPrimitiveCountCache[groupName]; return; } } //store the primitive and point start indices GA_Offset startPointOfs = args.pointCount; GA_Offset startPrimOfs = args.primCount; GA_PrimitiveGroup * primGrp; if (args.reusePrimitives) { Abc::P3fArraySamplePtr pSample = schema.getPositionsProperty().getValue(sampleSelector); std::string groupName = fixAttributeName(getFullName(polymesh)); primGrp = reuseMesh(groupName, pSample, startPointOfs); args.pointCount += pSample->size(); // Add # points //always present in myPrimitiveCountCache if args.reusePrimitives args.primCount += myPrimitiveCountCache[groupName]; } else { IPolyMeshSchema::Sample sample = schema.getValue( sampleSelector ); args.pointCount += sample.getPositions()->size(); // Add # points args.primCount += sample.getFaceCounts()->size(); // Add # faces std::string groupName = fixAttributeName(getFullName(polymesh)); primGrp = buildMesh(groupName, sample.getPositions(), sample.getFaceCounts(), sample.getFaceIndices()); } GA_Offset endPointOfs = args.pointCount; GA_Offset endPrimOfs = args.primCount; addUVs(args, polymesh.getSchema().getUVsParam(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs); addNormals(args, polymesh.getSchema().getNormalsParam(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); addArbitraryGeomParams(args, polymesh.getSchema().getArbGeomParams(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); //apply xforms via gdp->transform so that we don't have to think //about normals and other affected attributes if (args.includeXform && parentXform != M44d()) { UT_DMatrix4 dxform(parentXform.x); UT_Matrix4 xform(dxform); gdp->transform(xform, primGrp); } } void SOP_AlembicIn::buildCurves( Args & args, ICurves & curves, M44d parentXform, bool parentXformIsConstant) { ISampleSelector sampleSelector( args.abcTime ); ICurvesSchema &schema = curves.getSchema(); if (!schema.isConstant()) { args.isConstant = false; } // If the schema is constant and we've already cooked once, we can exit // early assuming that we're either not baking in tranforms or the inherited // transformations are constant.else if (args.reusePrimitives) else if (args.reusePrimitives) { if (!args.includeXform || parentXformIsConstant) { // Update point/prim counts Abc::P3fArraySamplePtr pSample = schema.getPositionsProperty().getValue(sampleSelector); std::string groupName = fixAttributeName(getFullName(curves)); args.pointCount += pSample->size(); // Add # points args.primCount += myPrimitiveCountCache[groupName]; return; } } //store the primitive and point start indices GA_Offset startPointOfs = args.pointCount; GA_Offset startPrimOfs = args.primCount; GA_PrimitiveGroup * primGrp; if (args.reusePrimitives) { Abc::P3fArraySamplePtr pSample = schema.getPositionsProperty().getValue(sampleSelector); std::string groupName = fixAttributeName(getFullName(curves)); primGrp = reuseMesh(groupName, pSample, startPointOfs); args.pointCount += pSample->size(); // Add # points //always present in myPrimitiveCountCache if args.reusePrimitives args.primCount += myPrimitiveCountCache[groupName]; } else { ICurvesSchema::Sample sample = schema.getValue( sampleSelector ); args.pointCount += sample.getPositions()->size(); // Add # points args.primCount += sample.getNumCurves(); // Add # curves std::string groupName = fixAttributeName(getFullName(curves)); primGrp = buildCurves(groupName, sample.getPositions(), sample.getCurvesNumVertices()); } GA_Offset endPointOfs = args.pointCount; GA_Offset endPrimOfs = args.primCount; addUVs(args, curves.getSchema().getUVsParam(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs); addNormals(args, curves.getSchema().getNormalsParam(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); addWidths(args, curves.getSchema().getWidthsParam(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs); addArbitraryGeomParams(args, curves.getSchema().getArbGeomParams(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); //apply xforms via gdp->transform so that we don't have to think //about normals and other affected attributes if (args.includeXform && parentXform != M44d()) { UT_DMatrix4 dxform(parentXform.x); UT_Matrix4 xform(dxform); gdp->transform(xform, primGrp); } } void SOP_AlembicIn::buildPoints( Args & args, IPoints & points, M44d parentXform, bool parentXformIsConstant) { ISampleSelector sampleSelector( args.abcTime ); IPointsSchema &schema = points.getSchema(); if (!schema.isConstant()) { args.isConstant = false; } // If the schema is constant and we've already cooked once, we can exit // early assuming that we're either not baking in tranforms or the inherited // transformations are constant.else if (args.reusePrimitives) else if (args.reusePrimitives) { if (!args.includeXform || parentXformIsConstant) { // Update point/prim counts Abc::P3fArraySamplePtr pSample = schema.getPositionsProperty().getValue(sampleSelector); args.pointCount += pSample->size(); // Add # points args.primCount += 1; return; } } //store the primitive and point start indices GA_Offset startPointOfs = args.pointCount; GA_Offset startPrimOfs = args.primCount; GA_PrimitiveGroup * primGrp; if (args.reusePrimitives) { Abc::P3fArraySamplePtr pSample = schema.getPositionsProperty().getValue(sampleSelector); std::string groupName = fixAttributeName(getFullName(points)); primGrp = reuseMesh(groupName, pSample, startPointOfs); args.pointCount += pSample->size(); // Add # points //always present in myPrimitiveCountCache if args.reusePrimitives args.primCount += 1; } else { IPointsSchema::Sample sample = schema.getValue( sampleSelector ); args.pointCount += sample.getPositions()->size(); // Add # points args.primCount += 1; // Add single particle system std::string groupName = fixAttributeName(getFullName(points)); primGrp = buildPoints(groupName, sample.getPositions(), sample.getIds(), sample.getVelocities()); } GA_Offset endPointOfs = args.pointCount; GA_Offset endPrimOfs = args.primCount; addWidths(args, points.getSchema().getWidthsParam(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs); addArbitraryGeomParams(args, points.getSchema().getArbGeomParams(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); //apply xforms via gdp->transform so that we don't have to think //about normals and other affected attributes if (args.includeXform && parentXform != M44d()) { UT_DMatrix4 dxform(parentXform.x); UT_Matrix4 xform(dxform); gdp->transform(xform, primGrp); } } //-***************************************************************************** void SOP_AlembicIn::buildNuPatch( Args & args, INuPatch & nupatch, M44d parentXform, bool parentXformIsConstant) { ISampleSelector sampleSelector( args.abcTime ); INuPatchSchema &schema = nupatch.getSchema(); if (!schema.isConstant()) { args.isConstant = false; } else if (args.reusePrimitives) { if (!args.includeXform || parentXformIsConstant) { Abc::P3fArraySamplePtr pSample = schema.getPositionsProperty().getValue(sampleSelector); args.pointCount += pSample->size(); // Add # points args.primCount += 1; return; } } //store the primitive and point start indices GA_Offset startPointOfs = args.pointCount; GA_Offset startPrimOfs = args.primCount; GEO_PrimNURBSurf * surfPrim = 0; GA_PrimitiveGroup * primGrp = 0; if (args.reusePrimitives) { surfPrim = dynamic_cast( gdp->getGEOPrimitiveByIndex(args.primCount)); Abc::P3fArraySamplePtr pSample = schema.getPositionsProperty().getValue(sampleSelector); //only update point positions for (size_t i = 0, e = pSample->size(); i < e; ++i) { GA_Offset pt = gdp->pointOffset(GA_Index(startPointOfs+i)); gdp->setPos3(pt, (*pSample)[i][0], (*pSample)[i][1], (*pSample)[i][2]); } std::string groupName = fixAttributeName(nupatch.getFullName().c_str()); primGrp = gdp->findPrimitiveGroup( groupName.c_str() ); args.pointCount += pSample->size(); // Add # points args.primCount += 1; } else { INuPatchSchema::Sample sample = schema.getValue( sampleSelector ); args.pointCount += sample.getPositions()->size(); // Add # points args.primCount += 1; int cols = sample.getUKnot()->size() - sample.getUOrder(); int rows = sample.getVKnot()->size() - sample.getVOrder(); GU_PrimNURBSurf *surf = GU_PrimNURBSurf::build( gdp, rows, // rows cols, // columns sample.getUOrder(), // U order sample.getVOrder(), // V order 0, // wrap U 0, // wrap V 0,//(uClosed) ? 0:1, // interpEndsU 0,//(vClosed) ? 0:1, // interpEndsV GEO_PATCH_QUADS); //copy in the u and v knots GA_KnotVector &uknots = surf->getUBasis()->getKnotVector(); GA_KnotVector &vknots = surf->getVBasis()->getKnotVector(); for (int i = 0; i < sample.getUKnot()->size(); ++i) uknots.setValue(i, sample.getUKnot()->get()[i]); for (int i = 0; i < sample.getVKnot()->size(); ++i) vknots.setValue(i, sample.getVKnot()->get()[i]); for (int v = 0; v < rows; ++v) { for( int u = 0; u < cols; ++u ) { const V3f & p = sample.getPositions()->get()[v * cols + u]; GA_Offset ptofs = surf->getPointOffset(v, u); gdp->setPos3(ptofs, p[0], p[1], p[2]); //std::cerr << "ptnum: " << surf->getPointIndex(v, u) << std::endl; } } //TODO, check for getPositionWeights() //For now, don't throw any W on there. surf->weights(false); std::string groupName = fixAttributeName(nupatch.getFullName().c_str()); primGrp = gdp->newPrimitiveGroup( groupName.c_str() ); addToGroup(primGrp, surf); surfPrim = surf; } GA_Offset endPointOfs = args.pointCount; GA_Offset endPrimOfs = args.primCount; if (surfPrim) { // Make sure this is reset back to 0 when we're done even in the case // of an exception. ArgsRowColumnReset argsReset(args, surfPrim->getNumRows(), surfPrim->getNumCols()); addArbitraryGeomParams(args, nupatch.getSchema().getArbGeomParams(), startPointOfs, endPointOfs, startPrimOfs, endPrimOfs, parentXformIsConstant); } //apply xforms via gdp->transform so that we don't have to think //about normals and other affected attributes if (args.includeXform && parentXform != M44d()) { UT_DMatrix4 dxform(parentXform.x); UT_Matrix4 xform(dxform); gdp->transform(xform, primGrp); } } //-***************************************************************************** GA_PrimitiveGroup * SOP_AlembicIn::reuseMesh(const std::string & groupName, P3fArraySamplePtr positions, GA_Offset startPointOfs) { GA_Offset pt = startPointOfs; for (size_t i = 0, e = positions->size(); i < e; ++i, ++pt) { gdp->setPos3(pt, (*positions)[i][0], (*positions)[i][1], (*positions)[i][2]); } return gdp->findPrimitiveGroup( groupName.c_str() ); } GA_PrimitiveGroup * SOP_AlembicIn::buildMesh( const std::string & groupName, P3fArraySamplePtr positions, Int32ArraySamplePtr counts, Int32ArraySamplePtr indices) { myPrimitiveCountCache[groupName] = counts->size(); GA_PrimitiveGroup *primGrp = 0; if ( !groupName.empty() ) { primGrp = gdp->newPrimitiveGroup( groupName.c_str() ); } exint totalnpts = positions->size(); GA_Offset startPtOfs = gdp->appendPointBlock(totalnpts); if (startPtOfs == GA_INVALID_OFFSET) return NULL; GEO_PolyCounts primsizes; exint totalnprims = counts->size(); for (exint i=0; iget()); if (startPrimOfs == GA_INVALID_OFFSET) return NULL; GA_Offset pt=startPtOfs; for (size_t i = 0, e = positions->size(); i < e; ++i,++pt) { gdp->setPos3(pt, (*positions)[i][0], (*positions)[i][1], (*positions)[i][2]); } if (primGrp) { GA_Offset primofs = startPrimOfs; for (size_t i = 0, e = totalnprims; i < e; ++i,++primofs) primGrp->addOffset(primofs); } return primGrp; } GA_PrimitiveGroup * SOP_AlembicIn::buildCurves( const std::string & groupName, P3fArraySamplePtr positions, Int32ArraySamplePtr counts) { myPrimitiveCountCache[groupName] = counts->size(); GA_PrimitiveGroup *primGrp = 0; if ( !groupName.empty() ) { primGrp = gdp->newPrimitiveGroup( groupName.c_str() ); } exint totalnpts = positions->size(); GA_Offset startPtOfs = gdp->appendPointBlock(totalnpts); if (startPtOfs == GA_INVALID_OFFSET) return NULL; GEO_PolyCounts primsizes; exint totalnprims = counts->size(); // Since ICurvesSchema doesn't provide indices, we need to build // it ourselves in order to use buildBlock() int totalnindices = 0; for (exint i=0; i indices; indices.resize(totalnindices); for (exint i=0; isize(); i < e; ++i,++pt) { gdp->setPos3(pt, (*positions)[i][0], (*positions)[i][1], (*positions)[i][2]); } if (primGrp) { GA_Offset primofs = startPrimOfs; for (size_t i = 0, e = totalnprims; i < e; ++i,++primofs) primGrp->addOffset(primofs); } return primGrp; } GA_PrimitiveGroup * SOP_AlembicIn::buildPoints( const std::string & groupName, P3fArraySamplePtr positions, UInt64ArraySamplePtr ids, V3fArraySamplePtr velocities) { myPrimitiveCountCache[groupName] = 1; size_t npts = positions->size(); GA_RWAttributeRef idRef; GA_RWAttributeRef vRef; if (ids && ids->size() == positions->size()) idRef = addInt64Tuple(*gdp, GA_ATTRIB_POINT, "id", 1); if (velocities && velocities->size() == positions->size()) vRef = addVelocity(*gdp, GA_ATTRIB_POINT); GA_RWHandleID id_h; if (idRef.isValid()) id_h.bind(idRef.getAttribute()); GA_RWHandleV3 v_h; if (vRef.isValid()) v_h.bind(vRef.getAttribute()); GA_Offset startPtOfs = gdp->appendPointBlock(npts); if (startPtOfs == GA_INVALID_OFFSET) return NULL; GA_Offset pt = startPtOfs; for ( size_t i = 0; i < npts; ++i, ++pt ) { gdp->setPos3(pt, (*positions)[i][0], (*positions)[i][1], (*positions)[i][2]); if (id_h.isValid()) { id_h.set(pt, (int64)(*ids)[i]); } if (v_h.isValid()) { v_h.set(pt, UT_Vector3F((*velocities)[i].getValue())); } } GA_PrimitiveGroup *primGrp = 0; if ( !groupName.empty() ) { primGrp = gdp->newPrimitiveGroup( groupName.c_str() ); } GU_PrimParticle *part = GU_PrimParticle::build(gdp, npts, 0); if (primGrp) { addToGroup(primGrp, part); } pt = startPtOfs; for ( exint ptN = 0; ptN < npts; ++ptN, ++pt) { part->appendParticle(gdp->pointOffset(pt)); } return primGrp; } //-***************************************************************************** void newSopOperator(OP_OperatorTable *table) { OP_Operator *alembic_op = new OP_Operator( "ref_alembic", // Internal name "Reference Alembic", // GUI name SOP_AlembicIn::myConstructor, // Op Constructr SOP_AlembicIn::myTemplateList, // GUI Definition 0, 0, // Min,Max # of Inputs 0, OP_FLAG_GENERATOR); // Local Variables/Generator alembic_op->setIconName("SOP_alembic"); table->addOperator(alembic_op); } namespace { void DecomposeXForm( const Imath::M44d &mat, Imath::V3d &scale, Imath::V3d &shear, Imath::Quatd &rotation, Imath::V3d &translation ) { Imath::M44d mat_remainder(mat); // Extract Scale, Shear Imath::extractAndRemoveScalingAndShear(mat_remainder, scale, shear); // Extract translation translation.x = mat_remainder[3][0]; translation.y = mat_remainder[3][1]; translation.z = mat_remainder[3][2]; // Extract rotation rotation = extractQuat(mat_remainder); } M44d RecomposeXForm( const Imath::V3d &scale, const Imath::V3d &shear, const Imath::Quatd &rotation, const Imath::V3d &translation ) { Imath::M44d scale_mtx, shear_mtx, rotation_mtx, translation_mtx; scale_mtx.setScale(scale); shear_mtx.setShear(shear); rotation_mtx = rotation.toMatrix44(); translation_mtx.setTranslation(translation); return scale_mtx * shear_mtx * rotation_mtx * translation_mtx; } // when amt is 0, a is returned inline double lerp(double a, double b, double amt) { return (a + (b-a)*amt); } Imath::V3d lerp(const Imath::V3d &a, const Imath::V3d &b, double amt) { return Imath::V3d(lerp(a[0], b[0], amt), lerp(a[1], b[1], amt), lerp(a[2], b[2], amt)); } //-***************************************************************************** // Utility functions for the python bindings static void appendFile(std::vector &filenames, const char *name) { UT_String realname; // complete a path search in case it is in the geometry path UT_PathSearch::getInstance(UT_HOUDINI_GEOMETRY_PATH)-> findFile(realname, name); filenames.push_back(realname.toStdString()); } static void appendFileList(std::vector &filenames, PY_PyObject *fileList) { if (!fileList) return; if (PY_PyString_Check(fileList)) { const char *fileStr = PY_PyString_AsString(fileList); if (fileStr && strlen(fileStr)) appendFile(filenames, fileStr); } else if (PY_PySequence_Check(fileList)) { int numFiles = PY_PySequence_Size(fileList); for (int i = 0; i < numFiles; ++i) { PY_PyObject *fileObj = PY_PySequence_GetItem(fileList, i); if (PY_PyString_Check(fileObj)) { const char *fileStr = PY_PyString_AsString(fileObj); if (fileStr && strlen(fileStr)) appendFile(filenames, fileStr); } } } } //-***************************************************************************** // Python bindings PY_PyObject * Py_AlembicGetLocalXform(PY_PyObject *self, PY_PyObject *args) { PY_PyObject *fileList; const char * objectPath = NULL; double sampleTime = 0.0; bool isConstant = true; M44d localXform; if (!PY_PyArg_ParseTuple(args, "Osd", &fileList, &objectPath, &sampleTime)) return NULL; try { std::vector filenames; appendFileList(filenames, fileList); if (!filenames.size()) PY_Py_RETURN_NONE; ArchiveCacheEntryRcPtr cacheEntry = LoadArchive(filenames); if (cacheEntry->archive.valid() ) { bool found = false; #if 0 static int count = 0; static UT_StopWatch timer; if (count == 0) timer.start(); count++; if (count % 500 == 0) fprintf(stderr, "%d calls %g\n", count, timer.lap()); #endif IObject currentObject; if (cacheEntry->findTransform(objectPath, localXform)) found = true; else { currentObject = cacheEntry->getObject(objectPath); } if (!found && currentObject.valid() && IXform::matches( currentObject.getHeader())) { IXform xformObject(currentObject, kWrapExisting); isConstant = xformObject.getSchema().isConstant(); TimeSamplingPtr timeSampling = xformObject.getSchema().getTimeSampling(); size_t numSamples = xformObject.getSchema().getNumSamples(); chrono_t inTime = sampleTime; chrono_t outTime = sampleTime; if (numSamples > 1) { const chrono_t epsilon = 1.0 / 10000.0; std::pair floorIndex = timeSampling->getFloorIndex(sampleTime, numSamples); //make sure we're not equal enough if (fabs(floorIndex.second - sampleTime) > epsilon) { //make sure we're not before the first sample if (floorIndex.second < sampleTime) { //make sure there's another sample available afterwards if (floorIndex.first+1 < numSamples) { inTime = floorIndex.second; outTime = timeSampling->getSampleTime( floorIndex.first+1); } } } } //interpolate if necessary if (inTime != outTime ) { XformSample inSample = xformObject.getSchema().getValue( ISampleSelector(inTime)); XformSample outSample = xformObject.getSchema().getValue( ISampleSelector(outTime)); double t = (sampleTime - inTime) / (outTime - inTime); Imath::V3d s_l,s_r,h_l,h_r,t_l,t_r; Imath::Quatd quat_l,quat_r; DecomposeXForm(inSample.getMatrix(), s_l, h_l, quat_l, t_l); DecomposeXForm(outSample.getMatrix(), s_r, h_r, quat_r, t_r); if ((quat_l ^ quat_r) < 0) { quat_r = -quat_r; } localXform = RecomposeXForm(lerp(s_l, s_r, t), lerp(h_l, h_r, t), Imath::slerp(quat_l, quat_r, t), lerp(t_l, t_r, t)); } else { XformSample xformSample = xformObject.getSchema().getValue( ISampleSelector(sampleTime)); localXform = xformSample.getMatrix(); } } } } catch (const std::exception & /*e*/) { } PY_PyObject* matrixTuple = PY_PyTuple_New(16); for (PY_Py_ssize_t i = 0; i < 16; ++i) { PY_PyTuple_SET_ITEM(matrixTuple, i, PY_PyFloat_FromDouble(localXform[i / 4][i % 4])); } PY_PyObject* result = PY_PyTuple_New(2); PY_PyTuple_SET_ITEM(result, 0, matrixTuple); PY_PyTuple_SET_ITEM(result, 1, PY_PyInt_FromLong(isConstant)); return result; } //-************************************************************************* PY_PyObject * Py_AlembicWalkNode(IObject obj) { PY_PyObject* result = PY_PyTuple_New(3); PY_PyTuple_SET_ITEM(result, 0, PY_PyString_FromString(obj.getName().c_str())); const AbcA::ObjectHeader & header = obj.getHeader(); if (IXform::matches(header)) { IXform xformObject(obj, kWrapExisting); if (xformObject.getSchema().isConstant()) { // constant transform PY_PyTuple_SET_ITEM(result, 1, PY_PyString_FromString("cxform")); } else { PY_PyTuple_SET_ITEM(result, 1, PY_PyString_FromString("xform")); } } else if (IPolyMesh::matches(header)) { PY_PyTuple_SET_ITEM(result, 1, PY_PyString_FromString("polymesh")); } else if (ISubD::matches(header)) { PY_PyTuple_SET_ITEM(result, 1, PY_PyString_FromString("subdmesh")); } else if (ICamera::matches(header)) { PY_PyTuple_SET_ITEM(result, 1, PY_PyString_FromString("camera")); } else if (IFaceSet::matches(header)) { PY_PyTuple_SET_ITEM(result, 1, PY_PyString_FromString("faceset")); } else if (ICurves::matches(header)) { PY_PyTuple_SET_ITEM(result, 1, PY_PyString_FromString("curves")); } else if (IPoints::matches(header)) { PY_PyTuple_SET_ITEM(result, 1, PY_PyString_FromString("points")); } else if (INuPatch::matches(header)) { PY_PyTuple_SET_ITEM(result, 1, PY_PyString_FromString("nupatch")); } else { PY_PyTuple_SET_ITEM(result, 1, PY_PyString_FromString("unknown")); } PY_PyObject* childList = PY_PyTuple_New( obj.getNumChildren()); PY_PyTuple_SET_ITEM(result, 2, childList); for (size_t i = 0, e = obj.getNumChildren(); i < e; ++i) { PY_PyTuple_SET_ITEM(childList, i, Py_AlembicWalkNode(obj.getChild(i))); } return result; } //-************************************************************************* PY_PyObject * Py_AlembicGetSceneHierarchy(PY_PyObject *self, PY_PyObject *args) { PY_PyObject *fileList; const char * objectPath = NULL; if (!PY_PyArg_ParseTuple(args, "Os", &fileList, &objectPath )) return NULL; try { std::vector filenames; appendFileList(filenames, fileList); if (!filenames.size()) PY_Py_RETURN_NONE; ArchiveCacheEntryRcPtr cacheEntry = LoadArchive(filenames); if (cacheEntry->archive.valid()) { IObject currentObject = cacheEntry->getObject(objectPath); return Py_AlembicWalkNode(currentObject); } } catch (const std::exception & e) { PY_PyErr_SetString(PY_PyExc_RuntimeError(), e.what()); return NULL; } PY_Py_RETURN_NONE; } //-************************************************************************* PY_PyObject * Py_AlembicClearArchiveCache(PY_PyObject *self, PY_PyObject *args) { g_archiveCache->clear(); PY_Py_RETURN_NONE; } PY_PyObject * Py_AlembicSetArchiveMaxCacheSize(PY_PyObject *self, PY_PyObject *args) { unsigned int value; if (!PY_PyArg_ParseTuple(args, "I", &value)) return NULL; g_maxCache = value; PY_Py_RETURN_NONE; } PY_PyObject * Py_AlembicGetArchiveMaxCacheSize(PY_PyObject *self, PY_PyObject *args) { return PY_PyInt_FromLong((long) g_maxCache); } //-************************************************************************* void Py_AlembicWalkNodeForMenu(IObject obj, PY_PyObject * result, bool isRoot=false) { //For now, depth first. Hopefully a tree later. if (!isRoot) { PY_PyObject * fullName = PY_PyString_FromString( obj.getFullName().c_str()); //add twice because the menu input wants that. PY_PyList_Append(result, fullName); PY_PyList_Append(result, fullName); PY_Py_DECREF(fullName); } for (size_t i = 0, e = obj.getNumChildren(); i < e; ++i) { Py_AlembicWalkNodeForMenu(obj.getChild(i), result); } } //-************************************************************************* PY_PyObject * Py_AlembicGetObjectPathListForMenu(PY_PyObject *self, PY_PyObject *args) { PY_PyObject *fileList; if (!PY_PyArg_ParseTuple(args, "O", &fileList)) return NULL; PY_PyObject * result = NULL; try { std::vector filenames; appendFileList(filenames, fileList); if (!filenames.size()) PY_Py_RETURN_NONE; ArchiveCacheEntryRcPtr cacheEntry = LoadArchive(filenames); if (cacheEntry->objectPathMenuList != NULL) { result = cacheEntry->objectPathMenuList; PY_Py_INCREF(result); } else { result = PY_PyList_New(0); cacheEntry->objectPathMenuList = result; PY_Py_INCREF(result); if (cacheEntry->archive.valid()) { IObject root = cacheEntry->archive.getTop(); Py_AlembicWalkNodeForMenu(root, result, /*isRoot=*/true); } } } catch (const std::exception & /*e*/) { //PY_PyErr_SetString(PY_PyExc_RuntimeError(), e.what()); //return NULL; } if (result == NULL) { result = PY_PyList_New(0); } return result; } //-************************************************************************* PY_PyObject * Py_AlembicGetCameraDict(PY_PyObject *self, PY_PyObject *args) { PY_PyObject *fileList; const char * objectPath = NULL; double sampleTime = 0.0; if (!PY_PyArg_ParseTuple(args, "Osd", &fileList, &objectPath, &sampleTime)) return NULL; bool isConstant = true; PY_PyObject * resultDict = PY_PyDict_New(); try { std::vector filenames; appendFileList(filenames, fileList); if (!filenames.size()) PY_Py_RETURN_NONE; ArchiveCacheEntryRcPtr cacheEntry = LoadArchive(filenames); if (cacheEntry->archive.valid() ) { IObject currentObject = cacheEntry->getObject(objectPath); if (currentObject.valid() && ICamera::matches( currentObject.getHeader())) { ICamera cameraObject(currentObject, kWrapExisting); isConstant = cameraObject.getSchema().isConstant(); CameraSample cameraSample = cameraObject.getSchema().getValue( ISampleSelector(sampleTime)); //Express in houdini terms? PY_PyObject * val = NULL; val = PY_PyFloat_FromDouble(cameraSample.getFocalLength()); PY_PyDict_SetItemString(resultDict, "focal", val); PY_Py_DECREF(val); val = PY_PyFloat_FromDouble(cameraSample.getNearClippingPlane()); PY_PyDict_SetItemString(resultDict, "near", val); PY_Py_DECREF(val); val = PY_PyFloat_FromDouble(cameraSample.getFarClippingPlane()); PY_PyDict_SetItemString(resultDict, "far", val); PY_Py_DECREF(val); val = PY_PyFloat_FromDouble(cameraSample.getFocusDistance()); PY_PyDict_SetItemString(resultDict, "focus", val); PY_Py_DECREF(val); double top, bottom, left, right; cameraSample.getScreenWindow(top, bottom, left, right); double winx = cameraSample.getHorizontalFilmOffset() * cameraSample.getLensSqueezeRatio() / cameraSample.getHorizontalAperture(); double winy = cameraSample.getVerticalFilmOffset() * cameraSample.getLensSqueezeRatio() / cameraSample.getVerticalAperture(); //TODO, full 2D transformations Abc::V2d postScale(1.0, 1.0); for ( size_t i = 0; i < cameraSample.getNumOps(); ++i ) { const FilmBackXformOp & op = cameraSample.getOp(i); if ( op.isScaleOp() ) { postScale *= op.getScale(); } } //TODO overscan double winsizex = cameraSample.getLensSqueezeRatio() / postScale[0]; //TODO overscan double winsizey = cameraSample.getLensSqueezeRatio() / postScale[1]; val = PY_PyFloat_FromDouble(winx); PY_PyDict_SetItemString(resultDict, "winx", val); PY_Py_DECREF(val); val = PY_PyFloat_FromDouble(winy); PY_PyDict_SetItemString(resultDict, "winy", val); PY_Py_DECREF(val); val = PY_PyFloat_FromDouble(winsizex); PY_PyDict_SetItemString(resultDict, "winsizex", val); PY_Py_DECREF(val); val = PY_PyFloat_FromDouble(winsizey); PY_PyDict_SetItemString(resultDict, "winsizey", val); PY_Py_DECREF(val); val = PY_PyFloat_FromDouble( cameraSample.getHorizontalAperture()*10.0); PY_PyDict_SetItemString(resultDict, "aperture", val); PY_Py_DECREF(val); } } } catch (const std::exception & e) { PY_PyErr_SetString(PY_PyExc_RuntimeError(), e.what()); return NULL; } return resultDict; } } void HOMextendLibrary() { { // A PY_InterpreterAutoLock will grab the Python global interpreter // lock (GIL). It's important that we have the GIL before making // any calls into the Python API. PY_InterpreterAutoLock interpreter_auto_lock; // We'll create a new module named "_hom_extensions", and add functions // to it. We don't give a docstring here because it's given in the // Python implementation below. static PY_PyMethodDef alembic_hom_extension_methods[] = { {"alembicGetLocalXform", Py_AlembicGetLocalXform, PY_METH_VARARGS(), ""}, {"alembicGetSceneHierarchy", Py_AlembicGetSceneHierarchy, PY_METH_VARARGS(), ""}, {"alembicClearArchiveCache", Py_AlembicClearArchiveCache, PY_METH_VARARGS(), ""}, {"alembicSetArchiveMaxCacheSize", Py_AlembicSetArchiveMaxCacheSize, PY_METH_VARARGS(), ""}, {"alembicGetArchiveMaxCacheSize", Py_AlembicGetArchiveMaxCacheSize, PY_METH_VARARGS(), ""}, {"alembicGetObjectPathListForMenu", Py_AlembicGetObjectPathListForMenu, PY_METH_VARARGS(), ""}, {"alembicGetCameraDict", Py_AlembicGetCameraDict, PY_METH_VARARGS(), ""}, { NULL, NULL, 0, NULL } }; PY_Py_InitModule("_alembic_hom_extensions", alembic_hom_extension_methods); } PYrunPythonStatementsAndExpectNoErrors( "def _alembicGetCameraDict(self, archivePath, objectPath, sampleTime):\n" " '''Return camera information.'''\n" " import _alembic_hom_extensions\n" " return _alembic_hom_extensions.alembicGetCameraDict(archivePath, objectPath, sampleTime)\n" "__import__('hou').ObjNode.alembicGetCameraDict = _alembicGetCameraDict\n" "del _alembicGetCameraDict\n"); } alembic-1.8.9/houdini/SOP_AlembicIn/SOP_AlembicIn.h000066400000000000000000000202041507001531700216420ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef SOP_ALEMBICIN_H #define SOP_ALEMBICIN_H #include #include #include #include #include using namespace Alembic::AbcGeom; #include /// The sop_IAlembicWalker needs to be in a public namespace for forward /// declarations. class sop_IAlembicWalker; /// SOP to read Alembic geometry class SOP_AlembicIn : public SOP_Node { public: //-------------------------------------------------------------------------- // Standard hdk declarations static OP_Node *myConstructor(OP_Network *net, const char *name, OP_Operator *entry); static PRM_Template myTemplateList[]; typedef std::vector PathList; /// Clear a file out of the read-cache. If the filename is null, the /// entire cache is cleared. static void clearCacheFile(const std::vector *filenames=NULL); void appendFileNames(std::vector &filenames, fpreal t); protected: //-------------------------------------------------------------------------- // Standard hdk declarations SOP_AlembicIn(OP_Network *net, const char *name, OP_Operator *op); virtual ~SOP_AlembicIn(); virtual bool updateParmsFlags(); virtual bool unloadData(); virtual OP_ERROR cookMySop(OP_Context &context); virtual void nodeUnlocked(); private: GA_ROAttributeRef attachDetailStringData(const std::string &attrName, const std::string &value); struct Args { double abcTime; GA_Offset pointCount; GA_Offset primCount; bool includeXform; bool isConstant; // Attributes are constant bool isTopologyConstant; // Flag whether topology is constant bool reusePrimitives; // Reuse existing primitives // normally set to 0 but useful for interpolation of // varying GeomParams across NuPatch int activePatchRows; int activePatchCols; // Attribute name map const std::map *nameMap; UT_Interrupt *boss; }; struct ArgsRowColumnReset { Args &m_args; ArgsRowColumnReset(Args &args, int rows, int cols) : m_args(args) { m_args.activePatchRows = rows; m_args.activePatchCols = cols; } ~ArgsRowColumnReset() { m_args.activePatchRows = m_args.activePatchCols = 0; } }; class InterruptedException : public std::runtime_error { public: InterruptedException( const std::string & what_arg ) : std::runtime_error( what_arg ){} }; void walkObject( Args & args, sop_IAlembicWalker &pathBuf, IObject parent, const ObjectHeader &ohead, PathList::const_iterator I, PathList::const_iterator E, M44d parentXform, bool parentXformIsConstant); std::string getFullName( IObject object ); void buildSubD( Args & args, ISubD & subd, M44d parentXform, bool parentXformIsConstant); void buildPolyMesh( Args & args, IPolyMesh & polymesh, M44d parentXform, bool parentXformIsConstant); void buildNuPatch( Args & args, INuPatch & nupatch, M44d parentXform, bool paretnXformIsConstant); void buildCurves( Args & args, ICurves & curves, M44d parentXform, bool parentXformIsConstant); void buildPoints( Args & args, IPoints & curves, M44d parentXform, bool parentXformIsConstant); GA_PrimitiveGroup * buildMesh(const std::string & groupName, P3fArraySamplePtr positions, Int32ArraySamplePtr counts, Int32ArraySamplePtr indices); GA_PrimitiveGroup * buildCurves(const std::string & groupName, P3fArraySamplePtr positions, Int32ArraySamplePtr counts); GA_PrimitiveGroup * buildPoints(const std::string & groupName, P3fArraySamplePtr positions, UInt64ArraySamplePtr ids, V3fArraySamplePtr velocities); GA_PrimitiveGroup * reuseMesh(const std::string &groupName, P3fArraySamplePtr positions, GA_Offset startPointOfs); bool addOrFindWidthAttribute(GA_AttributeOwner owner, GA_RWAttributeRef & attrIdx); bool addOrFindTextureAttribute(GA_AttributeOwner owner, GA_RWAttributeRef & attrIdx); bool addOrFindNormalAttribute(GA_AttributeOwner owner, GA_RWAttributeRef & attrIdx); void addWidths(Args &args, IFloatGeomParam param, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs); void addUVs(Args & args, IV2fGeomParam param, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs); void addNormals(Args & args, IN3fGeomParam param, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs, bool parentXformIsConstant); void addArbitraryGeomParams(Args & args, ICompoundProperty parent, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs, bool parentXformIsConstant); template void processArbitraryGeomParam( Args & args, ICompoundProperty parent, const PropertyHeader & propHeader, GA_Storage attrStorage, GA_TypeInfo attrTypeInfo, const GA_RWAttributeRef & existingAttr, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs, bool parentXformIsConstant); template void applyArbitraryGeomParamSample( Args & args, geomParamSampleT & paramSample, const GA_RWAttributeRef & attrIdx, size_t totalExtent, GA_Offset startPointOfs, GA_Offset endPointOfs, GA_Offset startPrimOfs, GA_Offset endPrimOfs); UT_String myFileObjectCache; bool myTopologyConstant; bool myEntireSceneIsConstant; std::map myPrimitiveCountCache; int myConstantPointCount; // Point count for constant topology int myConstantPrimitiveCount; // Primitive count for constant topology int myConstantUniqueId; // Detail unique id for constant topology }; #endif alembic-1.8.9/houdini/SOP_AlembicIn/SOP_AlembicIn.svg000066400000000000000000000121001507001531700222060ustar00rootroot00000000000000 image/svg+xml alembic-1.8.9/lib/000077500000000000000000000000001507001531700136725ustar00rootroot00000000000000alembic-1.8.9/lib/Alembic/000077500000000000000000000000001507001531700152265ustar00rootroot00000000000000alembic-1.8.9/lib/Alembic/Abc/000077500000000000000000000000001507001531700157135ustar00rootroot00000000000000alembic-1.8.9/lib/Alembic/Abc/All.h000066400000000000000000000061221507001531700165750ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_All_h #define Alembic_Abc_All_h #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif alembic-1.8.9/lib/Alembic/Abc/ArchiveInfo.cpp000066400000000000000000000125111507001531700206140ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** void GetArchiveInfo( IArchive & iArchive, std::string & oApplicationWriter, std::string & oAlembicVersion, Util::uint32_t & oAlembicApiVersion, std::string & oDateWritten, std::string & oUserDescription, double & oDCCFPS) { if ( ! iArchive.getPtr() ) { return; } AbcA::MetaData md = iArchive.getPtr()->getMetaData(); oApplicationWriter = md.get( kApplicationNameKey ); oAlembicVersion = md.get( "_ai_AlembicVersion" ); oAlembicApiVersion = iArchive.getArchiveVersion(); oDateWritten = md.get( kDateWrittenKey ); oUserDescription = md.get( kUserDescriptionKey ); oDCCFPS = atof( md.get( kDCCFPSKey ).c_str() ); } void GetArchiveInfo( IArchive & iArchive, std::string & oApplicationWriter, std::string & oAlembicVersion, Util::uint32_t & oAlembicApiVersion, std::string & oDateWritten, std::string & oUserDescription) { double unusedFps; GetArchiveInfo( iArchive, oApplicationWriter, oAlembicVersion, oAlembicApiVersion, oDateWritten, oUserDescription, unusedFps ); } void GetArchiveStartAndEndTime( IArchive & iArchive, double & oStartTime, double & oEndTime ) { double startTime = DBL_MAX; double endTime = -DBL_MAX; double startSingleTime = DBL_MAX; double endSingleTime = -DBL_MAX; double startDefaultTime = DBL_MAX; double endDefaultTime = -DBL_MAX; for ( uint32_t i = 0; i < iArchive.getNumTimeSamplings(); ++i ) { index_t idx = iArchive.getMaxNumSamplesForTimeSamplingIndex( i ); if ( idx == INDEX_UNKNOWN ) { continue; } AbcA::TimeSamplingPtr ts = iArchive.getTimeSampling( i ); if ( !ts ) { continue; } if ( idx > 1 && i != 0 ) { startTime = std::min( ts->getSampleTime( 0 ), startTime ); endTime = std::max( ts->getSampleTime( idx - 1 ), endTime ); } else if ( idx == 1 && i != 0 ) { startSingleTime = std::min( ts->getSampleTime( 0 ), startSingleTime ); endSingleTime = std::max( ts->getSampleTime( 0 ), endSingleTime ); } else if ( idx > 0 && i == 0 ) { startDefaultTime = ts->getSampleTime( 0 ); endDefaultTime = ts->getSampleTime( idx - 1 ); } } // if we had a valid animated start and end time we will use only that if ( startTime != DBL_MAX && endTime != -DBL_MAX ) { oStartTime = startTime; oEndTime = endTime; } // this is for the cases where we have custom time samplings but // they only have 1 sample else if ( startSingleTime != DBL_MAX && endSingleTime != -DBL_MAX ) { oStartTime = startSingleTime; oEndTime = endSingleTime; } // no other valid time was yet to be found, but we found a valid // default time with at least one sample, so we will use it. else if ( startDefaultTime != DBL_MAX && endDefaultTime != -DBL_MAX ) { oStartTime = startDefaultTime; oEndTime = endDefaultTime; } else { oStartTime = DBL_MAX; oEndTime = -DBL_MAX; } } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/ArchiveInfo.h000066400000000000000000000204651507001531700202700ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_ArchiveInfo_h #define Alembic_Abc_ArchiveInfo_h #include #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** // Alembic archive information: // Useful utilities that readers and writers can use to provide // useful annotations into the alembic file. //-***************************************************************************** // Some MetaData key constants static const char * kApplicationNameKey = "_ai_Application"; static const char * kDateWrittenKey = "_ai_DateWritten"; static const char * kUserDescriptionKey = "_ai_Description"; static const char * kDCCFPSKey = "_ai_DCC_FPS"; //-***************************************************************************** template OArchive CreateArchiveWithInfo( //! We need to pass in a constructor which provides //! an explicit link to the concrete implementation of //! AbcCoreAbstract that we're using. ARCHIVE_CTOR iCtor, //! File name const std::string &iFileName, //! Application specific information about what is writing the file const std::string & iApplicationWriter, //! Extra information, could be arguments to the tool that is //! writing the file. const std::string & iUserDescription, //! Optional meta data or error handling policy const Argument &iArg0 = Argument(), //! Optional meta data or error handling policy const Argument &iArg1 = Argument() ); //-***************************************************************************** template OArchive CreateArchiveWithInfo( //! We need to pass in a constructor which provides //! an explicit link to the concrete implementation of //! AbcCoreAbstract that we're using. ARCHIVE_CTOR iCtor, //! File name const std::string &iFileName, //! Optional FPS hint that the DCC used at write time double iDCCFPS, //! Application specific information about what is writing the file const std::string & iApplicationWriter, //! Extra information, could be arguments to the tool that is //! writing the file. const std::string & iUserDescription, //! Optional meta data or error handling policy const Argument &iArg0 = Argument(), //! Optional meta data or error handling policy const Argument &iArg1 = Argument() ); //-***************************************************************************** ALEMBIC_EXPORT void GetArchiveInfo( //! The Archive whose meta data will be inspected IArchive & iArchive, //! Application specific information about what wrote the file std::string & oApplicationWriter, //! What version of Alembic wrote the file (and when it was built) std::string & oAlembicVersion, //! Numeric version of the Alembic API that wrote the file Util::uint32_t & oAlembicApiVersion, //! The data that the file was originally written std::string & oDateWritten, //! Extra information, could be arguments to the tool that wrote the file. std::string & oUserDescription ); //-***************************************************************************** ALEMBIC_EXPORT void GetArchiveInfo( //! The Archive whose meta data will be inspected IArchive & iArchive, //! Application specific information about what wrote the file std::string & oApplicationWriter, //! What version of Alembic wrote the file (and when it was built) std::string & oAlembicVersion, //! Numeric version of the Alembic API that wrote the file Util::uint32_t & oAlembicApiVersion, //! The data that the file was originally written std::string & oDateWritten, //! Extra information, could be arguments to the tool that wrote the file. std::string & oUserDescription, //! Optional hint about what FPS was being used by the DCC when this archive //! was created. double & oDCCFPS); //-***************************************************************************** //! Convenience function which gets a start and end time for the archive using //! only IArchive::getMaxNumSamplesForTimeSamplingIndex. The hierarchy is //! NOT walked. //! If the archive was written prior to 1.1.3 or no samples were written for //! any of the properties DBL_MAX will be set for oStartTime //! and -DBL_MAX will be set for oEndTime. ALEMBIC_EXPORT void GetArchiveStartAndEndTime( //! The Archive to be inspected IArchive & iArchive, //! The start time for the archive in seconds double & oStartTime, //! The end time for the archive in seconds double & oEndTime ); //-***************************************************************************** template OArchive CreateArchiveWithInfo( ARCHIVE_CTOR iCtor, const std::string &iFileName, double iDCCFPS, const std::string &iApplicationWriter, const std::string &iUserDescription, const Argument &iArg0, const Argument &iArg1 ) { AbcA::MetaData md = GetMetaData( iArg0, iArg1 ); ErrorHandler::Policy policy = GetErrorHandlerPolicyFromArgs( iArg0, iArg1 ); if ( iApplicationWriter != "" ) { md.set( kApplicationNameKey, iApplicationWriter ); } time_t rawtimeNow; time( &rawtimeNow ); char dateBuf [128]; #if defined _WIN32 || defined _WIN64 ctime_s( dateBuf, 128, &rawtimeNow); #else ctime_r( &rawtimeNow, dateBuf ); #endif std::size_t bufLen = strlen( dateBuf ); if ( bufLen > 0 && dateBuf[bufLen - 1] == '\n' ) { dateBuf[bufLen - 1] = '\0'; } md.set( kDateWrittenKey, dateBuf ); if ( iUserDescription != "" ) { md.set( kUserDescriptionKey, iUserDescription ); } if ( iDCCFPS > 0.0 ) { md.set( kDCCFPSKey, std::to_string( iDCCFPS ) ); } return OArchive( iCtor, iFileName, md, policy ); } template OArchive CreateArchiveWithInfo( ARCHIVE_CTOR iCtor, const std::string &iFileName, const std::string &iApplicationWriter, const std::string &iUserDescription, const Argument &iArg0, const Argument &iArg1 ) { return CreateArchiveWithInfo( iCtor, iFileName, 0, iApplicationWriter, iUserDescription, iArg0, iArg1 ); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/Argument.h000066400000000000000000000256371507001531700176630ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_Argument_h #define Alembic_Abc_Argument_h #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** class Arguments { public: Arguments( ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy, const AbcA::MetaData &iMetaData = AbcA::MetaData(), AbcA::TimeSamplingPtr iTimeSampling = AbcA::TimeSamplingPtr(), uint32_t iTimeIndex = 0, SchemaInterpMatching iMatch = kNoMatching, SparseFlag iSparse = kFull ) : m_errorHandlerPolicy( iPolicy ), m_metaData( iMetaData ), m_timeSampling( iTimeSampling ), m_timeSamplingIndex( iTimeIndex ), m_matching( iMatch ), m_sparse( iSparse ) {} void operator()( const uint32_t & iTimeSamplingIndex) { m_timeSamplingIndex = iTimeSamplingIndex; } void operator()( const ErrorHandler::Policy &iPolicy ) { m_errorHandlerPolicy = iPolicy; } void operator()( const AbcA::MetaData &iMetaData ) { m_metaData = iMetaData; } void operator()( const AbcA::TimeSamplingPtr & iTimeSampling ) { m_timeSampling = iTimeSampling; } void operator()( const SchemaInterpMatching &iMatching ) { m_matching = iMatching; } void operator()( const SparseFlag &iSparse ) { m_sparse = iSparse; } ErrorHandler::Policy getErrorHandlerPolicy() const { return m_errorHandlerPolicy; } const AbcA::MetaData &getMetaData() const { return m_metaData; } AbcA::TimeSamplingPtr getTimeSampling() const { return m_timeSampling; } uint32_t getTimeSamplingIndex() const { return m_timeSamplingIndex; } SchemaInterpMatching getSchemaInterpMatching() const { return m_matching; } bool isSparse() const { return m_sparse == kSparse; } private: ErrorHandler::Policy m_errorHandlerPolicy; AbcA::MetaData m_metaData; AbcA::TimeSamplingPtr m_timeSampling; uint32_t m_timeSamplingIndex; SchemaInterpMatching m_matching; SparseFlag m_sparse; }; //-***************************************************************************** // Right now there are 6 types of arguments that you'd pass into // our various classes for construction. // ErrorHandlerPolicy - always defaults to QuietNoop // MetaData - always defaults to "" // matching - schema interpretation matching // TimeSampling - always defaults to default uniform // TimeSamplingIndex - always defaults to 0 // Sparse - always defaults to kFull class Argument { public: Argument() : m_whichVariant( kArgumentNone ) {} Argument( ErrorHandler::Policy iPolicy ) : m_whichVariant( kArgumentErrorHandlerPolicy ), m_variant( iPolicy ) {} Argument( Alembic::Util::uint32_t iTsIndex ) : m_whichVariant( kArgumentTimeSamplingIndex ), m_variant( iTsIndex ) {} Argument( const AbcA::MetaData &iMetaData ) : m_whichVariant( kArgumentMetaData ), m_variant( &iMetaData ) {} Argument( const AbcA::TimeSamplingPtr &iTsPtr ) : m_whichVariant( kArgumentTimeSamplingPtr ), m_variant( &iTsPtr ) {} Argument( SchemaInterpMatching iMatch ) : m_whichVariant( kArgumentSchemaInterpMatching ), m_variant( iMatch ) {} Argument( SparseFlag iSparse ) : m_whichVariant( kArgumentSparse ), m_variant( iSparse ) {} void setInto( Arguments &iArgs ) const { switch ( m_whichVariant ) { case kArgumentErrorHandlerPolicy: iArgs( m_variant.policy ); break; case kArgumentTimeSamplingIndex: iArgs( m_variant.timeSamplingIndex ); break; case kArgumentMetaData: iArgs( *m_variant.metaData ); break; case kArgumentTimeSamplingPtr: iArgs( *m_variant.timeSamplingPtr ); break; case kArgumentSchemaInterpMatching: iArgs( m_variant.schemaInterpMatching ); break; case kArgumentSparse: iArgs( m_variant.sparseFlag ); break; // no-op case kArgumentNone: break; default: // we added something that we forgot to support in the switch assert(false); break; } } private: const Argument& operator= (const Argument&); enum ArgumentWhichFlag { kArgumentNone, kArgumentErrorHandlerPolicy, kArgumentTimeSamplingIndex, kArgumentMetaData, kArgumentTimeSamplingPtr, kArgumentSchemaInterpMatching, kArgumentSparse } const m_whichVariant; union ArgumentVariant { ArgumentVariant() : timeSamplingIndex( 0 ) {} explicit ArgumentVariant( ErrorHandler::Policy iPolicy ) : policy( iPolicy ) {} explicit ArgumentVariant( Alembic::Util::uint32_t iTsIndex ) : timeSamplingIndex( iTsIndex ) {} explicit ArgumentVariant( const AbcA::MetaData * iMetaData ) : metaData( iMetaData ) {} explicit ArgumentVariant( const AbcA::TimeSamplingPtr * iTsPtr ) : timeSamplingPtr( iTsPtr ) {} explicit ArgumentVariant( SchemaInterpMatching iMatch ) : schemaInterpMatching( iMatch ) {} explicit ArgumentVariant( SparseFlag iSparse ) : sparseFlag( iSparse ) {} ErrorHandler::Policy policy; Alembic::Util::uint32_t timeSamplingIndex; const AbcA::MetaData * metaData; const AbcA::TimeSamplingPtr * timeSamplingPtr; SchemaInterpMatching schemaInterpMatching; SparseFlag sparseFlag; } const m_variant; }; //-***************************************************************************** //! This is for when you need to get the error handler policy out inside //! a constructor header. template inline ErrorHandler::Policy GetErrorHandlerPolicy ( SOMETHING iSomething, const Argument &iArg0, const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument(), const Argument &iArg3 = Argument() ) { Arguments args( GetErrorHandlerPolicy( iSomething ) ); iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); iArg3.setInto( args ); return args.getErrorHandlerPolicy(); } //-***************************************************************************** inline ErrorHandler::Policy GetErrorHandlerPolicyFromArgs ( const Argument &iArg0, const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument(), const Argument &iArg3 = Argument() ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); iArg3.setInto( args ); return args.getErrorHandlerPolicy(); } //-***************************************************************************** inline AbcA::MetaData GetMetaData ( const Argument &iArg0, const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument(), const Argument &iArg3 = Argument() ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); iArg3.setInto( args ); return args.getMetaData(); } //-***************************************************************************** inline AbcA::TimeSamplingPtr GetTimeSampling ( const Argument &iArg0, const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument(), const Argument &iArg3 = Argument() ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); iArg3.setInto( args ); return args.getTimeSampling(); } //-***************************************************************************** inline uint32_t GetTimeSamplingIndex ( const Argument &iArg0, const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument(), const Argument &iArg3 = Argument() ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); iArg3.setInto( args ); return args.getTimeSamplingIndex(); } //-***************************************************************************** inline SchemaInterpMatching GetSchemaInterpMatching ( const Argument &iArg0, const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument(), const Argument &iArg3 = Argument() ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); iArg3.setInto( args ); return args.getSchemaInterpMatching(); } //-***************************************************************************** inline bool IsSparse ( const Argument &iArg0, const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument(), const Argument &iArg3 = Argument() ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); iArg3.setInto( args ); return args.isSparse(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/Base.h000066400000000000000000000062761507001531700167510ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_Base_h #define Alembic_Abc_Base_h #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** class Base { protected: Base() {} explicit Base( ErrorHandler::Policy iPolicy ) : m_errorHandler( iPolicy ) {} Base( const Base &iCopy ) : m_errorHandler( iCopy.m_errorHandler ) {} Base& operator=( const Base &iCopy ) { m_errorHandler = iCopy.m_errorHandler; return *this; } bool valid() const { return m_errorHandler.valid(); } void reset() { m_errorHandler.clear(); } public: ErrorHandler &getErrorHandler() const { return m_errorHandler; } ErrorHandler::Policy getErrorHandlerPolicy() const { return m_errorHandler.getPolicy(); } private: mutable ErrorHandler m_errorHandler; }; //-***************************************************************************** inline ErrorHandler::Policy GetErrorHandlerPolicy( const Base& iClass ) { return iClass.getErrorHandlerPolicy(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/CMakeLists.txt000066400000000000000000000057221507001531700204610ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** LIST(APPEND CXX_FILES Abc/ArchiveInfo.cpp Abc/ErrorHandler.cpp Abc/IArchive.cpp Abc/IArrayProperty.cpp Abc/ICompoundProperty.cpp Abc/IObject.cpp Abc/ISampleSelector.cpp Abc/IScalarProperty.cpp Abc/OArchive.cpp Abc/OArrayProperty.cpp Abc/OCompoundProperty.cpp Abc/OObject.cpp Abc/OScalarProperty.cpp Abc/Reference.cpp Abc/SourceName.cpp ) SET(CXX_FILES "${CXX_FILES}" PARENT_SCOPE) INSTALL(FILES All.h Base.h ErrorHandler.h Foundation.h Argument.h ArchiveInfo.h IArchive.h IArrayProperty.h IBaseProperty.h ICompoundProperty.h IObject.h ISampleSelector.h IScalarProperty.h ISchema.h ISchemaObject.h ITypedArrayProperty.h ITypedScalarProperty.h OArchive.h OArrayProperty.h OBaseProperty.h OCompoundProperty.h OObject.h OScalarProperty.h OSchema.h OSchemaObject.h OTypedArrayProperty.h OTypedScalarProperty.h Reference.h SourceName.h TypedArraySample.h TypedPropertyTraits.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Alembic/Abc ) IF (USE_TESTS) ADD_SUBDIRECTORY(Tests) ENDIF() alembic-1.8.9/lib/Alembic/Abc/ErrorHandler.cpp000066400000000000000000000064261507001531700210160ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** void ErrorHandler::operator()( std::exception &iExc, const std::string &iMsg ) { handleIt( ( iMsg + "\nERROR: EXCEPTION:\n" ) + iExc.what() ); } //-***************************************************************************** void ErrorHandler::operator()( const std::string &iErr, const std::string &iMsg ) { handleIt( ( iMsg + "\nERROR:\n" ) + iErr ); } //-***************************************************************************** void ErrorHandler::operator()( ErrorHandler::UnknownExceptionFlag kFlag, const std::string &iMsg ) { handleIt( iMsg + "\nERROR: UNKNOWN EXCEPTION\n" ); } //-***************************************************************************** void ErrorHandler::handleIt( const std::string &iMsg ) { if ( m_policy == kNoisyNoopPolicy ) { std::cerr << iMsg << std::endl; m_errorLog.append( iMsg ); m_errorLog.append( "\n" ); } else if ( m_policy == kQuietNoopPolicy ) { m_errorLog.append( iMsg ); m_errorLog.append( "\n" ); } else { ABCA_THROW( iMsg ); } } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/ErrorHandler.h000066400000000000000000000175551507001531700204700ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_ErrorHandler_h #define Alembic_Abc_ErrorHandler_h #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** class ALEMBIC_EXPORT ErrorHandler { public: enum Policy { kQuietNoopPolicy, kNoisyNoopPolicy, kThrowPolicy }; enum UnknownExceptionFlag { kUnknownException }; ErrorHandler() : m_policy( kThrowPolicy ) , m_errorLog( "" ) {} ErrorHandler( Policy iPolicy ) : m_policy( iPolicy ) , m_errorLog( "" ) {} //! Default copy constructor //! Default assignment operator void operator()( std::exception &iExc, const std::string &iCtx = "" ); void operator()( const std::string &iErrMsg, const std::string &iCtx = "" ); void operator()( UnknownExceptionFlag iUef, const std::string &iCtx = "" ); Policy getPolicy() const { return m_policy; } void setPolicy( Policy iPolicy ) { m_policy = iPolicy; } const std::string getErrorLog() const { return m_errorLog; } bool valid() const { return ( m_errorLog == "" ); } void clear() { m_errorLog = ""; } class Context { public: Context( ErrorHandler &iEhnd, const char *iCtxMsg ) : m_handler( iEhnd ), m_message( iCtxMsg ) {} void operator()( std::exception &iExc ) { m_handler( iExc, m_message ); } void operator()( const std::string &iMsg ) { m_handler( iMsg, m_message ); } void operator()( UnknownExceptionFlag iUef ) { m_handler( iUef, m_message ); } private: const Context& operator= (const Context&); ErrorHandler &m_handler; const char *m_message; }; private: void handleIt( const std::string &iErr ); Policy m_policy; std::string m_errorLog; }; //-***************************************************************************** //-***************************************************************************** inline ErrorHandler::Policy GetErrorHandlerPolicy( AbcA::ArchiveWriterPtr /* iClass */ ) { return ErrorHandler::kThrowPolicy; } inline ErrorHandler::Policy GetErrorHandlerPolicy( AbcA::ObjectWriterPtr /* iClass */ ) { return ErrorHandler::kThrowPolicy; } inline ErrorHandler::Policy GetErrorHandlerPolicy( AbcA::CompoundPropertyWriterPtr /* iClass */ ) { return ErrorHandler::kThrowPolicy; } inline ErrorHandler::Policy GetErrorHandlerPolicy( AbcA::ScalarPropertyWriterPtr /* iClass */ ) { return ErrorHandler::kThrowPolicy; } inline ErrorHandler::Policy GetErrorHandlerPolicy( AbcA::ArrayPropertyWriterPtr /* iClass */ ) { return ErrorHandler::kThrowPolicy; } //-***************************************************************************** inline ErrorHandler::Policy GetErrorHandlerPolicy( AbcA::ArchiveReaderPtr /* iClass */ ) { return ErrorHandler::kThrowPolicy; } inline ErrorHandler::Policy GetErrorHandlerPolicy( AbcA::ObjectReaderPtr /* iClass */ ) { return ErrorHandler::kThrowPolicy; } inline ErrorHandler::Policy GetErrorHandlerPolicy( AbcA::CompoundPropertyReaderPtr /* iClass */ ) { return ErrorHandler::kThrowPolicy; } inline ErrorHandler::Policy GetErrorHandlerPolicy( AbcA::ScalarPropertyReaderPtr /* iClass */ ) { return ErrorHandler::kThrowPolicy; } inline ErrorHandler::Policy GetErrorHandlerPolicy( AbcA::ArrayPropertyReaderPtr /* iClass */ ) { return ErrorHandler::kThrowPolicy; } //-***************************************************************************** #define ALEMBIC_ABC_SAFE_CALL_BEGIN( CONTEXT ) \ do \ { \ ::Alembic::Abc::ErrorHandler::Context \ __err( this->getErrorHandler(), ( CONTEXT ) ); \ try \ { //-***************************************************************************** #define ALEMBIC_ABC_SAFE_CALL_END_RESET() \ } \ catch ( std::exception &exc ) \ { \ this->reset(); \ __err( exc ); \ } \ catch ( ... ) \ { \ this->reset(); \ __err( ::Alembic::Abc:: \ ErrorHandler::kUnknownException ); \ } \ } \ while( 0 ) //-***************************************************************************** #define ALEMBIC_ABC_SAFE_CALL_END() \ } \ catch ( std::exception &exc ) \ { \ __err( exc ); \ } \ catch ( ... ) \ { \ __err( ::Alembic::Abc:: \ ErrorHandler::kUnknownException ); \ } \ } \ while( 0 ) } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/Foundation.h000066400000000000000000000203451507001531700201760ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2016, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_Foundation_h #define Alembic_Abc_Foundation_h #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** // Bring 'em ALL in. namespace AbcA = ::Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS; using namespace AbcA; //-***************************************************************************** //! Flag for specifying whether to match interpretations or schemas //! When we create objects that have certain expected properties, data formats //! or layouts, we use things called "SchemaTitles" and "Interpretations", //! both of which are just strings, for providing a hint as to the meaning //! of CompoundProperties and SimpleProperties, respectively. //! This flag is used by the wrapper classes to indicate how they will //! assert a match of schemaTitle or interpretation. //-***************************************************************************** enum SchemaInterpMatching { kStrictMatching, kNoMatching, kSchemaTitleMatching }; //-***************************************************************************** //! We want to be able to use our wrapper classes to wrap existing writer //! and reader objects from AbcCoreAbstract. However, the constructors //! for these wrapper classes have trouble distinguishing between the //! user request to wrap an existing writer, vs the request to create a new //! writer. //! While for some of the properties herein this is actually not ambiguous, //! we insist on the use of this flag because it makes code and intention //! more readable. //-***************************************************************************** enum WrapExistingFlag { kWrapExisting }; //-***************************************************************************** //! This flag exists to indicate that the "top" object or compound property //! is desired - when getting the top object from the Archive or //! getting the top compound property from the Object. //-***************************************************************************** enum TopFlag { kTop }; //-***************************************************************************** //! Flag used during write which indicates whether we are writing out the //! full schema, or just parts of it. //-***************************************************************************** enum SparseFlag { kFull, kSparse }; //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** // IMPORTED IMATH TYPES //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** using Imath::V2s; using Imath::V2i; using Imath::V2f; using Imath::V2d; using Imath::V3s; using Imath::V3i; using Imath::V3f; using Imath::V3d; using Imath::Box2s; using Imath::Box2i; using Imath::Box2f; using Imath::Box2d; using Imath::Box3s; using Imath::Box3i; using Imath::Box3f; using Imath::Box3d; using Imath::M33f; using Imath::M33d; using Imath::M44f; using Imath::M44d; using Imath::Quatf; using Imath::Quatd; using Imath::C3h; using Imath::C3f; using Imath::C3c; using Imath::C4h; using Imath::C4f; using Imath::C4c; typedef V3f N3f; typedef V3d N3d; //-***************************************************************************** //-***************************************************************************** // OBJECT EXTRACTION FUNCTIONS // These are intrusive methods used by the Abc constructors. //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** inline AbcA::CompoundPropertyWriterPtr GetCompoundPropertyWriterPtr( AbcA::CompoundPropertyWriterPtr iPtr ) { return iPtr; } //-***************************************************************************** inline AbcA::CompoundPropertyReaderPtr GetCompoundPropertyReaderPtr( AbcA::CompoundPropertyReaderPtr iPtr ) { return iPtr; } //-***************************************************************************** //-***************************************************************************** // OBJECT EXTRACTION FUNCTIONS // These are intrusive methods used by the templated Abc constructors. //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** inline AbcA::ObjectWriterPtr GetObjectWriterPtr( AbcA::ObjectWriterPtr iPtr ) { return iPtr; } //-***************************************************************************** inline AbcA::ObjectReaderPtr GetObjectReaderPtr( AbcA::ObjectReaderPtr iPtr ) { return iPtr; } //-***************************************************************************** //-***************************************************************************** // ARCHIVE EXTRACTION FUNCTIONS // These are intrusive methods used by the templated Abc constructors. //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** inline AbcA::ArchiveWriterPtr GetArchiveWriterPtr( AbcA::ArchiveWriterPtr iPtr ) { return iPtr; } //-***************************************************************************** inline AbcA::ArchiveReaderPtr GetArchiveReaderPtr( AbcA::ArchiveReaderPtr iPtr ) { return iPtr; } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/IArchive.cpp000066400000000000000000000123011507001531700201060ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** IArchive::~IArchive() { // Nothing - just here as a support entry point for debugging } //-***************************************************************************** std::string IArchive::getName() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArchive::getName()" ); return m_archive->getName(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, // so return a NO-OP value return ""; } //-***************************************************************************** IObject IArchive::getTop() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArchive::getTop()" ); return IObject( m_archive->getTop() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so here is a default behavior. return IObject(); } //-***************************************************************************** AbcA::ReadArraySampleCachePtr IArchive::getReadArraySampleCachePtr() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArchive::getReadArraySampleCachePtr" ); return m_archive->getReadArraySampleCachePtr(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, // so return a NO-OP value. return AbcA::ReadArraySampleCachePtr(); } //-***************************************************************************** AbcA::TimeSamplingPtr IArchive::getTimeSampling( uint32_t iIndex ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArchive:::getTimeSampling" ); return m_archive->getTimeSampling( iIndex ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so here is a default behavior. return AbcA::TimeSamplingPtr(); } //-***************************************************************************** uint32_t IArchive::getNumTimeSamplings( ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArchive:::getNumTimeSampling" ); return m_archive->getNumTimeSamplings( ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so here is a default behavior. return 0; } //-***************************************************************************** index_t IArchive::getMaxNumSamplesForTimeSamplingIndex( uint32_t iIndex ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArchive::getMaxNumSamplesForTimeSamplingIndex" ); return m_archive->getMaxNumSamplesForTimeSamplingIndex( iIndex ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so here is a default behavior. return INDEX_UNKNOWN; } //-***************************************************************************** int32_t IArchive::getArchiveVersion( ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArchive:::getArchiveVersion" ); return m_archive->getArchiveVersion( ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so here is a default behavior. return 0; } //-***************************************************************************** void IArchive::setReadArraySampleCachePtr( AbcA::ReadArraySampleCachePtr iPtr ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArchive::setReadArraySampleCachePtr" ); m_archive->setReadArraySampleCachePtr( iPtr ); ALEMBIC_ABC_SAFE_CALL_END(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/IArchive.h000066400000000000000000000200061507001531700175540ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_IArchive_h #define Alembic_Abc_IArchive_h #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { class IObject; //-***************************************************************************** class ALEMBIC_EXPORT IArchive : public Base { public: //! By convention, we always define "this_type" in every Abc //! class. This convention is relied upon by the unspecified-bool-type //! cast typedef IArchive this_type; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty IArchive function set. //! ... IArchive() {} //! The explicit constructor opens an existing archive with the //! given file name. Additional arguments that may be passed are the //! error handler policy and a pointer to a cache instance. By //! default, an archive-local cache will be created. template IArchive( //! We need to pass in a constructor which provides //! an explicit link to the concrete implementation of //! AbcCoreAbstract that we're using. ARCHIVE_CTOR iCtor, //! The file name. const std::string &iFileName, ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy, AbcA::ReadArraySampleCachePtr iCachePtr = AbcA::ReadArraySampleCachePtr()); //! This attaches an IArchive wrapper around an existing //! ArchiveReaderPtr, with an optional error handling policy. IArchive( //! The pointer //! ... AbcA::ArchiveReaderPtr iPtr, //! Optional error handling policy //! ... ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy ) : m_archive( iPtr ) { // Set the error handling policy. getErrorHandler().setPolicy( iPolicy ); } // Deprecated in favor of the constructor above IArchive( AbcA::ArchiveReaderPtr iPtr, WrapExistingFlag /* iWrap */, ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy ) : m_archive( iPtr ) { // Set the error handling policy. getErrorHandler().setPolicy( iPolicy ); } //! Destructor //! ... ~IArchive(); //! Default copy constructor //! Default assignment operator //-************************************************************************* // ARCHIVE WRITER FUNCTIONALITY //-************************************************************************* //! Returns the file name. //! It is an error to do so with an invalid object. std::string getName() const; //! This returns the single top-level IObject that exists //! automatically as part of the archive. IObject getTop() const; //! Get the read array sample cache. It may be a NULL pointer. //! Caches can be shared amongst separate archives, and caching //! will be disabled if a NULL cache is returned here. AbcA::ReadArraySampleCachePtr getReadArraySampleCachePtr(); //! Set the read array sample cache. It may also be a NULL pointer. //! Caches can be shared amongst separate archives, and caching //! will be disabled if a NULL cache is passed here. void setReadArraySampleCachePtr( AbcA::ReadArraySampleCachePtr iPtr ); //-************************************************************************* // ABC BASE MECHANISMS // These functions are used by Abc to deal with errors, rewrapping, // and so on. //-************************************************************************* //! getPtr, as usual, returns a shared ptr to the //! underlying AbcCoreAbstract object, in this case the //! ArchiveReaderPtr. AbcA::ArchiveReaderPtr getPtr() { return m_archive; } //! Reset returns this function et to an empty, default //! state. void reset() { m_archive.reset(); Base::reset(); } //! Returns the TimeSampling at a given index. AbcA::TimeSamplingPtr getTimeSampling( uint32_t iIndex ); //! Returns the total number of TimeSamplingPtrs in the Archive //! TimeSampling pool. uint32_t getNumTimeSamplings(); //! Returns the maximum number of samples written for the TimeSampling at //! the given index. If an illegal iIndex is specified, or a max //! number of samplings couldn't be found for that iIndex //! (for older archives pre 1.1.3) INDEX_UNKNOWN will be returned. index_t getMaxNumSamplesForTimeSamplingIndex( uint32_t iIndex ); //! Valid returns whether this function set is //! valid. bool valid() const { return ( Base::valid() && m_archive ); } //! Returns the Alembic library numeric version (see Foundation.h) //! of this archive file. int32_t getArchiveVersion(); //! The unspecified-bool-type operator casts the object to "true" //! if it is valid, and "false" otherwise. ALEMBIC_OPERATOR_BOOL( valid() ); private: AbcA::ArchiveReaderPtr m_archive; }; //-***************************************************************************** //! This function is used by the intrusive templated constructors //! for IObjects. inline AbcA::ArchiveReaderPtr GetArchiveReaderPtr( IArchive& iPrp ) { return iPrp.getPtr(); } //-***************************************************************************** //-***************************************************************************** template IArchive::IArchive( ARCHIVE_CTOR iCtor, const std::string &iFileName, ErrorHandler::Policy iPolicy, AbcA::ReadArraySampleCachePtr iCachePtr ) { // Set the error handling policy. getErrorHandler().setPolicy( iPolicy ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArchive::IArchive( iFileName )" ); m_archive = iCtor( iFileName, iCachePtr ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/IArrayProperty.cpp000066400000000000000000000175201507001531700213600ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** IArrayProperty::IArrayProperty( const ICompoundProperty & iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1 ) { init( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent ), iArg0, iArg1 ); } //-***************************************************************************** IArrayProperty::~IArrayProperty() { // Nothing for now. // Mostly here in case we need to add reference-counting debug code. } //-***************************************************************************** size_t IArrayProperty::getNumSamples() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getNumSamples()" ); return m_property->getNumSamples(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so return a default. return 0; } //-***************************************************************************** bool IArrayProperty::isConstant() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::isConstant()" ); return m_property->isConstant(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so return a default. return false; } //-***************************************************************************** bool IArrayProperty::isScalarLike() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::isScalarLike()" ); return m_property->isScalarLike(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so return a default. return false; } //-***************************************************************************** AbcA::TimeSamplingPtr IArrayProperty::getTimeSampling() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getTimeSampling()" ); return m_property->getTimeSampling(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so return a default. return AbcA::TimeSamplingPtr(); } //-***************************************************************************** void IArrayProperty::get( AbcA::ArraySamplePtr& oSamp, const ISampleSelector &iSS ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::get()" ); m_property->getSample( iSS.getIndex( m_property->getTimeSampling(), m_property->getNumSamples() ), oSamp ); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** void IArrayProperty::getAs( void * oSample, AbcA::PlainOldDataType iPod, const ISampleSelector &iSS ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getAs(PlainOldDataType)" ); m_property->getAs( iSS.getIndex( m_property->getTimeSampling(), m_property->getNumSamples() ), oSample, iPod ); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** void IArrayProperty::getAs( void * oSample, const ISampleSelector &iSS ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getAs()" ); m_property->getAs( iSS.getIndex( m_property->getTimeSampling(), m_property->getNumSamples() ), oSample, m_property->getDataType().getPod() ); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** bool IArrayProperty::getKey( AbcA::ArraySampleKey& oKey, const ISampleSelector &iSS ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getKey()" ); return m_property->getKey( iSS.getIndex( m_property->getTimeSampling(), m_property->getNumSamples() ), oKey ); ALEMBIC_ABC_SAFE_CALL_END(); // for error handler that don't throw return false; } //-***************************************************************************** void IArrayProperty::getDimensions( Util::Dimensions & oDim, const ISampleSelector &iSS ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getDimensions()" ); m_property->getDimensions( iSS.getIndex( m_property->getTimeSampling(), m_property->getNumSamples() ), oDim ); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** ICompoundProperty IArrayProperty::getParent() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::getParent()" ); return ICompoundProperty( m_property->getParent(), getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return ICompoundProperty(); } //-***************************************************************************** void IArrayProperty::init( AbcA::CompoundPropertyReaderPtr iParent, const std::string &iName, ErrorHandler::Policy iParentPolicy, const Argument &iArg0, const Argument &iArg1 ) { Arguments args( iParentPolicy ); iArg0.setInto( args ); iArg1.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArrayProperty::init()" ); const AbcA::PropertyHeader *pheader = iParent->getPropertyHeader( iName ); ABCA_ASSERT( pheader != NULL, "Nonexistent array property: " << iName ); m_property = iParent->getArrayProperty( iName ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/IArrayProperty.h000066400000000000000000000150431507001531700210230ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_IArrayProperty_h #define Alembic_Abc_IArrayProperty_h #include #include #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** class ALEMBIC_EXPORT IArrayProperty : public IBasePropertyT { public: //! By convention we always define this_type in Abc classes //! Used by unspecified-bool-type conversion below typedef IArrayProperty this_type; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty IArrayProperty function set. //! ... IArrayProperty() : IBasePropertyT() {} //! This constructor creates a new array property reader. //! The first argument is the parent ICompundProperty, from which the error //! handler policy for inheritance is also derived. The remaining optional //! arguments can be used to override the ErrorHandlerPolicy, and that's it. IArrayProperty( const ICompoundProperty & iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ); //! This attaches an IArrayProperty wrapper around an existing //! ArrayPropertyReaderPtr, with an optional error handling policy. IArrayProperty( //! The pointer //! ... AbcA::ArrayPropertyReaderPtr iPtr, //! Optional error handling policy //! ... const Argument &iArg0 = Argument() ) : IBasePropertyT( iPtr, GetErrorHandlerPolicy( iPtr, iArg0 ) ) {}; // Deprecated in favor of the constructor above IArrayProperty( AbcA::ArrayPropertyReaderPtr iPtr, WrapExistingFlag iWrapFlag, const Argument &iArg0 = Argument() ) : IBasePropertyT( iPtr, GetErrorHandlerPolicy( iPtr, iArg0 ) ) {}; //! Default copy constructor used //! Default assignment operator used. //! Destructor //! ... ~IArrayProperty(); //-************************************************************************* // ARRAY PROPERTY READER FUNCTIONALITY //-************************************************************************* //! Return the number of samples contained in the property. //! This can be any number, including zero. //! This returns the number of samples that were written, independently //! of whether or not they were constant. size_t getNumSamples() const; //! Ask if we're constant - no change in value amongst samples, //! regardless of the time sampling. bool isConstant() const; //! Ask if we are like a scalar - we have 1 and only 1 DataType per sample. bool isScalarLike() const; //! Time information. AbcA::TimeSamplingPtr getTimeSampling() const; //! Get a sample into the address of a datum. //! ... void get( AbcA::ArraySamplePtr& oSample, const ISampleSelector &iSS = ISampleSelector() ) const; //! Get a sample into the address of a datum as a particular POD type. void getAs( void *oSample, AbcA::PlainOldDataType iPod, const ISampleSelector &iSS = ISampleSelector() ); //! Get a sample into the address of a datum as the POD type of this //! array property. void getAs( void *oSample, const ISampleSelector &iSS = ISampleSelector() ); //! Get a key from an address of a datum. //! ... bool getKey( AbcA::ArraySampleKey& oKey, const ISampleSelector &iSS = ISampleSelector() ) const; //! Get the dimensions of the datum. void getDimensions( Util::Dimensions & oDim, const ISampleSelector &iSS = ISampleSelector() ) const; //! Return the parent compound property, handily wrapped in a //! ICompoundProperty wrapper. ICompoundProperty getParent() const; private: void init( AbcA::CompoundPropertyReaderPtr iParentObject, const std::string &iName, ErrorHandler::Policy iParentPolicy, const Argument &iArg0, const Argument &iArg1 ); }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/IBaseProperty.h000066400000000000000000000205151507001531700206170ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_IBaseProperty_h #define Alembic_Abc_IBaseProperty_h #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! Most of the functionality of properties (getting information about the //! properties and so on) is common to all property types, so we create //! a base class to contain all that functionality. //! This is purely a base class for other properties to derive from, //! it will never be created directly. template class IBasePropertyT : public Base { protected: //-************************************************************************* // TYPEDEFS AND IDENTIFIERS //-************************************************************************* typedef IBasePropertyT this_type; typedef IBasePropertyT operator_bool_base_type; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty IBasePropertyT function set. //! ... IBasePropertyT() {} //! This attaches an IBasePropertyT wrapper around an existing //! PROP_PTR, with an optional error handling policy. IBasePropertyT( //! The pointer //! ... PROP_PTR iPtr, //! Optional error handling policy //! ... ErrorHandler::Policy iPolicy ); //! Default copy constructor used //! Default assignment operator used. public: //-************************************************************************* // PROPERTY WRITER FUNCTIONALITY //-************************************************************************* //! Return the property's header. //! ... const AbcA::PropertyHeader & getHeader() const; //! This function returns the property's local name //! ... const std::string &getName() const { return getHeader().getName(); } //! This function returns the property's type //! ... AbcA::PropertyType getPropertyType() const { return getHeader().getPropertyType(); } //! Convenience to return whether the property is scalar. //! Same as getPropertyType() == kScalarProperty bool isScalar() const { return getPropertyType() == AbcA::kScalarProperty; } //! Convenience to return whether the property is array. //! Same as getPropertyType() == kArrayProperty bool isArray() const { return getPropertyType() == AbcA::kArrayProperty; } //! Convenience to return whether the property is compound. //! Same as getPropertyType() == kCompoundProperty bool isCompound() const { return getPropertyType() == AbcA::kCompoundProperty; } //! Convenience to return whether the property is simple (non-compound) //! Same as getPropertyType() != kCompoundProperty bool isSimple() const { return !isCompound(); } //! All properties have MetaData. This just returns the //! MetaData portion of the header that was used in creation. const AbcA::MetaData &getMetaData() const { return getHeader().getMetaData(); } //! Non-compound properties have a DataType. It is an error //! to call this function for CompoundProperties, and an exception will //! be thrown. This is a convenience function which just returns the //! DataType from the header that was used in creation. const AbcA::DataType &getDataType() const { return getHeader().getDataType(); } //! Non-compound properties have a TimeSamplingPtr. It is an error //! to call this function for CompoundProperties, and an exception will //! be thrown. This is a convenience function which just returns the //! TimeSamplingPtr from the header that was used in creation. AbcA::TimeSamplingPtr getTimeSampling() const { return getHeader().getTimeSampling(); } //! This function returns the property's object, handily //! wrapped in an IObject wrapper. IObject getObject() const; //-************************************************************************* // ABC BASE MECHANISMS // These functions are used by Abc to deal with errors, rewrapping, // and so on. //-************************************************************************* //! getPtr, as usual, returns a shared ptr to the //! underlying AbcCoreAbstract object, in this case the //! PROP_PTR. PROP_PTR getPtr() const { return m_property; } //! Reset returns this function set to an empty, default //! state. void reset() { m_property.reset(); Base::reset(); } //! Valid returns whether this function set is //! valid. bool valid() const { return ( Base::valid() && m_property ); } //! The unspecified-bool-type operator casts the object to "true" //! if it is valid, and "false" otherwise. ALEMBIC_OPERATOR_BOOL( valid() ); protected: PROP_PTR m_property; }; //-***************************************************************************** // TEMPLATE AND INLINE FUNCTIONS //-***************************************************************************** template inline IBasePropertyT::IBasePropertyT ( PROP_PTR iPtr, ErrorHandler::Policy iPolicy ) : m_property( iPtr ) { getErrorHandler().setPolicy( iPolicy ); } //-***************************************************************************** template const AbcA::PropertyHeader &IBasePropertyT::getHeader() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IBasePropertyT::getHeader()" ); return m_property->getHeader(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so have a default behavior. static const AbcA::PropertyHeader phd; return phd; }; //-***************************************************************************** template IObject IBasePropertyT::getObject() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IBasePropertyT::getObject()" ); return IObject( m_property->getObject(), getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return IObject(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/ICompoundProperty.cpp000066400000000000000000000161101507001531700220600ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** ICompoundProperty::ICompoundProperty( const ICompoundProperty & iParent, const std::string &iName, const Argument &iArg0 ) { init( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent ), iArg0 ); } //-***************************************************************************** ICompoundProperty::ICompoundProperty( AbcA::CompoundPropertyReaderPtr iPtr, const Argument &iArg0, const Argument &iArg1 ) : IBasePropertyT( iPtr, GetErrorHandlerPolicy( iPtr, iArg0, iArg1 ) ) { // Nothing! } //-***************************************************************************** ICompoundProperty::ICompoundProperty( AbcA::CompoundPropertyReaderPtr iPtr, WrapExistingFlag /* iWrapFlag */, const Argument &iArg0, const Argument &iArg1 ) : IBasePropertyT( iPtr, GetErrorHandlerPolicy( iPtr, iArg0, iArg1 ) ) { // Nothing! } //-***************************************************************************** ICompoundProperty::ICompoundProperty( const IObject & iObject, const Argument &iArg0, const Argument &iArg1 ) { init( iObject, iArg0, iArg1 ); } //-***************************************************************************** ICompoundProperty::ICompoundProperty( const IObject & iObject, TopFlag /* iTopFlag */, const Argument &iArg0, const Argument &iArg1 ) { init( iObject, iArg0, iArg1 ); } //-***************************************************************************** ICompoundProperty::~ICompoundProperty() { // Here for debug support } //-***************************************************************************** size_t ICompoundProperty::getNumProperties() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICompoundProperty::getNumProperties()" ); return m_property->getNumProperties(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return 0; } //-***************************************************************************** const AbcA::PropertyHeader &ICompoundProperty::getPropertyHeader( size_t iIdx ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICompoundProperty::getPropertyHeader()" ); return m_property->getPropertyHeader( iIdx ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. static const AbcA::PropertyHeader hd; return hd; } //-***************************************************************************** const AbcA::PropertyHeader * ICompoundProperty::getPropertyHeader( const std::string &iName ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICompoundProperty::getPropertyHeader()" ); return m_property->getPropertyHeader( iName ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return NULL; } //-***************************************************************************** ICompoundProperty ICompoundProperty::getParent() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICompoundProperty::getParent()" ); return ICompoundProperty( m_property->getParent(), getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return ICompoundProperty(); } //-***************************************************************************** void ICompoundProperty::init ( const IObject & iObject, const Argument &iArg0, const Argument &iArg1 ) { getErrorHandler().setPolicy( GetErrorHandlerPolicy( iObject, iArg0, iArg1 ) ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICompoundProperty::init( IObject )" ); m_property = iObject.getProperties().getPtr(); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } //-***************************************************************************** void ICompoundProperty::init( AbcA::CompoundPropertyReaderPtr iParent, const std::string &iName, ErrorHandler::Policy iParentPolicy, const Argument &iArg0 ) { Arguments args( iParentPolicy ); iArg0.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICompoundProperty::init()" ); ABCA_ASSERT( iParent, "invalid parent" ); const AbcA::PropertyHeader *pheader = iParent->getPropertyHeader( iName ); ABCA_ASSERT( pheader != NULL, "Nonexistent compound property: " << iName ); m_property = iParent->getCompoundProperty( iName ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/ICompoundProperty.h000066400000000000000000000151711507001531700215330ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_ICompoundProperty_h #define Alembic_Abc_ICompoundProperty_h #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** class ALEMBIC_EXPORT ICompoundProperty : public IBasePropertyT { public: //! By convention we always define this_type in Abc classes //! Used by unspecified-bool-type conversion below typedef ICompoundProperty this_type; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty ICompoundProperty function set. //! ... ICompoundProperty() : IBasePropertyT() {} //! This constructor creates a new compound property reader. //! The first argument is the parent ICompundProperty, from which the error //! handler policy for inheritance is also derived. The remaining optional //! arguments can be used to override the ErrorHandlerPolicy, and that's it. ICompoundProperty( const ICompoundProperty & iParent, const std::string & iName, const Argument & iArg0 = Argument() ); //! This attaches an ICompoundProperty wrapper around an existing //! CompoundPropertyReaderPtr, with an optional error handling policy. //! //! The extra argument is to support ISchema, which is publicly derived //! from ICompoundProperty (see ISchema.h). ICompoundProperty( AbcA::CompoundPropertyReaderPtr iPtr, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ); // Deprecated in favor of the constructor above ICompoundProperty( AbcA::CompoundPropertyReaderPtr iPtr, WrapExistingFlag /* iWrapFlag */, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ); //! This attaches an ICompoundProperty wrapper around the top //! properties of any object, with an optional error handling policy. //! //! The extra argument is to support ISchema, which is publicly derived //! from ICompoundProperty (see ISchema.h). ICompoundProperty( const IObject & iObject, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ); // Deprecated in favor of the constructor above ICompoundProperty( const IObject & iObject, TopFlag /* iTopFlag */, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ); //! Default copy constructor used //! Default assignment operator used. //! Destructor //! ... ~ICompoundProperty(); //-************************************************************************* // COMPOUND PROPERTY READER FUNCTIONALITY //-************************************************************************* //! Returns the number of properties contained in this ICompoundProperty size_t getNumProperties() const; //! Return the header of a child property. //! Property is selected by index. //! This will throw an exception on out-of-range access. const AbcA::PropertyHeader & getPropertyHeader( size_t i ) const; //! Return the header of a property name. //! This will return a NULL pointer if no header by that name is found. const AbcA::PropertyHeader * getPropertyHeader( const std::string &iName ) const; //! There is no distinction between already added properties //! and created properties with an AbcA::CompoundPropertyReader, therefore //! we have no need to expose "getProperty". Simply use the appropriate //! IScalarProperty, ICompoundProperty, or IArrayProperty //! wrappers. //! Return the parent compound property, handily wrapped in a //! ICompoundProperty wrapper. ICompoundProperty getParent() const; private: void init ( const IObject & iObject, const Argument &iArg0, const Argument &iArg1 ); void init( AbcA::CompoundPropertyReaderPtr iParentObject, const std::string &iName, ErrorHandler::Policy iParentPolicy, const Argument &iArg0 ); }; //-***************************************************************************** inline AbcA::CompoundPropertyReaderPtr GetCompoundPropertyReaderPtr ( ICompoundProperty &iPrp ) { return iPrp.getPtr(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/IObject.cpp000066400000000000000000000374151507001531700177500ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** // Nothing at the moment, this is just here as a debug entry point for // tracking down problems with reference counting. IObject::~IObject() { // Nothing for now. // Mostly here in case we need to add reference-counting debug code. //std::cout << "IObject::~IObject() name: " // << m_object->getName() // << std::endl // << "\tUse count of writer ptr: " // << m_object.use_count() << std::endl; } namespace { const AbcA::ObjectHeader g_ohd; } //-***************************************************************************** const AbcA::ObjectHeader &IObject::getHeader() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::getHeader()" ); if ( m_object ) { return m_object->getHeader(); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so have a default behavior. return g_ohd; }; //-***************************************************************************** const std::string &IObject::getName() const { // Get the name of the original object if ( m_instanceObject ) { return m_instanceObject->getHeader().getName(); } return m_object->getHeader().getName(); } //-***************************************************************************** const std::string &IObject::getFullName() const { if ( !m_instancedFullName.empty() ) { return m_instancedFullName; } return getHeader().getFullName(); } //-***************************************************************************** IArchive IObject::getArchive() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::getArchive()" ); // proxies and targets are currently required to be in the // same archive. Just use the m_object archive. if ( m_object ) { return IArchive( m_object->getArchive(), getErrorHandlerPolicy() ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return IArchive(); } namespace { // anonymous static inline std::string readInstanceSource( AbcA::CompoundPropertyReaderPtr iProp ) { if ( !iProp || !iProp->getPropertyHeader(".instanceSource") ) { return std::string(); } IStringProperty instanceSourceProp( iProp, ".instanceSource" ); if ( !instanceSourceProp ) return std::string(); return instanceSourceProp.getValue(); } static inline AbcA::ObjectReaderPtr objectReaderByName( AbcA::ObjectReaderPtr iObj, const std::string & iInstanceSource ); static inline AbcA::ObjectReaderPtr recurse( AbcA::ObjectReaderPtr iObj, const std::string & iInstanceSource, std::size_t iCurPos ) { std::size_t nextSlash = iInstanceSource.find( '/', iCurPos ); std::string childName; if ( nextSlash == std::string::npos ) { childName = iInstanceSource.substr( iCurPos ); } else { childName = iInstanceSource.substr( iCurPos, nextSlash - iCurPos ); } AbcA::ObjectReaderPtr child = iObj->getChild( childName ); if ( child && nextSlash != std::string::npos ) { // we hit an instance so we have to evaluate down to the correct spot if ( child->getMetaData().get("isInstance") == "1" ) { // get and recursively walk down this other path AbcA::CompoundPropertyReaderPtr prop = child->getProperties(); std::string instanceSource = readInstanceSource( prop ); child = objectReaderByName( child, instanceSource); } return recurse( child, iInstanceSource, nextSlash + 1 ); } // child not found, or we are on our last child return child; } //-***************************************************************************** static inline AbcA::ObjectReaderPtr objectReaderByName( AbcA::ObjectReaderPtr iObj, const std::string & iInstanceSource ) { if ( iInstanceSource.empty() || ! iObj ) return AbcA::ObjectReaderPtr(); std::size_t curPos = 0; if ( iInstanceSource[0] == '/' ) { curPos = 1; } AbcA::ObjectReaderPtr obj = iObj->getArchive()->getTop(); return recurse( obj, iInstanceSource, curPos ); } //-***************************************************************************** static inline std::string getParentFullName( const std::string& iChildFullName ) { size_t pos = iChildFullName.rfind('/'); if ( pos == std::string::npos || pos == 0 ) { return std::string(); } return iChildFullName.substr(0, pos); } } // end anonymous namespace //-***************************************************************************** IObject IObject::getParent() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::getParent()" ); if ( !m_instancedFullName.empty() ) { std::string parentFullName = getParentFullName( m_instancedFullName ); AbcA::ObjectReaderPtr parentPtr = m_object->getParent(); bool setFullName = false; // if the instanced full name doesn't match the parents full name // then we have an instanced situation where we need to carefully // walk the hierarchy to make sure we end up with the correct parent // If the names do match, then the parent isn't a part of the instance // and so we don't need to set that full name if ( parentPtr && !parentFullName.empty() && parentFullName != parentPtr->getFullName() ) { parentPtr = objectReaderByName( parentPtr, parentFullName ); setFullName = true; } IObject obj( parentPtr, getErrorHandlerPolicy() ); if ( setFullName ) { obj.setInstancedFullName( parentFullName ); } return obj; } else if ( m_object ) { return IObject( m_object->getParent(), getErrorHandlerPolicy() ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return IObject(); } //-***************************************************************************** size_t IObject::getNumChildren() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::getNumChildren()" ); if ( m_object ) { return m_object->getNumChildren(); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return 0; } //-***************************************************************************** const AbcA::ObjectHeader &IObject::getChildHeader( size_t iIdx ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::getChildHeader()" ); if ( m_object ) { return m_object->getChildHeader( iIdx ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. static const AbcA::ObjectHeader hd; return hd; } //-***************************************************************************** const AbcA::ObjectHeader * IObject::getChildHeader( const std::string &iName ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::getChildHeader( name )" ); if ( m_object ) { return m_object->getChildHeader( iName ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return NULL; } //-***************************************************************************** IObject IObject::getChild( size_t iChildIndex ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::getChild()" ); if ( m_object ) { IObject obj( m_object->getChild( iChildIndex ), getErrorHandlerPolicy() ); if ( !m_instancedFullName.empty() ) { obj.setInstancedFullName( m_instancedFullName + std::string("/") + obj.getName() ); } return obj; } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, return something in case. return IObject(); } //-***************************************************************************** IObject IObject::getChild( const std::string &iChildName ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::getChild()" ); if ( m_object ) { IObject obj( m_object->getChild( iChildName ), getErrorHandlerPolicy() ); if ( !m_instancedFullName.empty() ) { obj.setInstancedFullName( m_instancedFullName + std::string("/") + obj.getName() ); } return obj; } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, return something in case. return IObject(); } //-***************************************************************************** void IObject::reset() { m_instanceObject.reset(); m_instancedFullName.clear(); m_object.reset(); Base::reset(); } //-***************************************************************************** ICompoundProperty IObject::getProperties() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::getProperties()" ); if ( m_object ) { return ICompoundProperty( m_object->getProperties() ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return ICompoundProperty(); } //-***************************************************************************** bool IObject::getPropertiesHash( Util::Digest & oDigest ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::getPropertiesHash()" ); if ( m_object ) { return m_object->getPropertiesHash( oDigest ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return false; } //-***************************************************************************** bool IObject::getChildrenHash( Util::Digest & oDigest ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::getChildrenHash()" ); if ( m_object ) { return m_object->getChildrenHash( oDigest ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return false; } //-***************************************************************************** bool IObject::isInstanceRoot() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::isInstanceRoot()" ); if ( m_instanceObject ) { return true; } ALEMBIC_ABC_SAFE_CALL_END(); return false; } //-***************************************************************************** bool IObject::isInstanceDescendant() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::isInstanceDescendant()" ); if ( !m_instancedFullName.empty() ) { return true; } ALEMBIC_ABC_SAFE_CALL_END(); return false; } //-***************************************************************************** std::string IObject::instanceSourcePath() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::instanceSourcePath()" ); if ( !m_instanceObject ) { return std::string(); } AbcA::CompoundPropertyReaderPtr props = m_instanceObject->getProperties(); return readInstanceSource( props ); ALEMBIC_ABC_SAFE_CALL_END(); return std::string(); } //-***************************************************************************** void IObject::setInstancedFullName( const std::string& parentPath ) const { m_instancedFullName = parentPath; } //-***************************************************************************** bool IObject::isChildInstance( size_t iChildIndex ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::isChildInstanced(size_t iChildIndex)" ); IObject child = getChild( iChildIndex ); if ( child.valid() ) { return child.isInstanceRoot(); } ALEMBIC_ABC_SAFE_CALL_END(); return false; } //-***************************************************************************** bool IObject::isChildInstance( const std::string &iChildName ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::isChildInstance(const std::string &iChildName)" ); IObject child = getChild( iChildName ); if ( child.valid() ) { return child.isInstanceRoot(); } ALEMBIC_ABC_SAFE_CALL_END(); return false; } //-***************************************************************************** void IObject::init( IArchive & iArchive, const Argument &iArg0 ) { // Set the error handling policy getErrorHandler().setPolicy( GetErrorHandlerPolicy( iArchive, iArg0 ) ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::init( IArchive )" ); m_object = iArchive.getTop().getPtr(); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } //-***************************************************************************** void IObject::init( AbcA::ObjectReaderPtr iParent, const std::string &iName, ErrorHandler::Policy iPolicy ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IObject::init()" ); getErrorHandler().setPolicy( iPolicy ); m_object = iParent->getChild( iName ); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** void IObject::initInstance() { // not an instance so m_instanceObject will stay empty if ( !m_object || m_object->getMetaData().get("isInstance") != "1") { return; } AbcA::CompoundPropertyReaderPtr propsPtr = m_object->getProperties(); std::string instanceSource = readInstanceSource( propsPtr ); AbcA::ObjectReaderPtr targetObject = objectReaderByName( m_object, instanceSource ); m_instanceObject = m_object; m_object = targetObject; // initialize the full name to the instance full name if ( m_instanceObject != 0 ) { m_instancedFullName = m_instanceObject->getFullName(); } } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/IObject.h000066400000000000000000000300001507001531700173740ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_IObject_h #define Alembic_Abc_IObject_h #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { class ICompoundProperty; //-***************************************************************************** class ALEMBIC_EXPORT IObject : public Base { public: //! By convention, we always define "this_type" in every Abc //! class. This convention is relied upon by the unspecified-bool-type //! conversion. typedef IObject this_type; typedef IObject operator_bool_base_type; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty IObject function set. //! ... IObject() {} //! This function creates a new object reader. //! The first argument is the Abc IObject parent from which the error //! handler policy for inheritance is also derived. The remaining optional //! arguments can be used to override the ErrorHandlerPolicy. IObject( const IObject & iParent, const std::string &iName, const Argument &iArg0 = Argument() ) { init( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent, iArg0 ) ); initInstance(); } //! This attaches an IObject wrapper around an existing //! ObjectReaderPtr, with an optional error handling policy. IObject( AbcA::ObjectReaderPtr iPtr, const Argument &iArg0 = Argument() ) : m_object( GetObjectReaderPtr( iPtr ) ) { // Set the error handling policy getErrorHandler().setPolicy( GetErrorHandlerPolicy( iPtr, iArg0 ) ); initInstance(); } // Deprecated in favor of the constructor above IObject( AbcA::ObjectReaderPtr iPtr, WrapExistingFlag /* iFlag */, const Argument &iArg0 = Argument() ) : m_object( GetObjectReaderPtr( iPtr ) ) { // Set the error handling policy getErrorHandler().setPolicy( GetErrorHandlerPolicy( iPtr, iArg0 ) ); initInstance(); } //! This attaches an IObject wrapper around the top //! object of an archive. IObject( IArchive & iArchive, const Argument &iArg0 = Argument() ) { init( iArchive, iArg0 ); } // Deprecated in favor of the constructor above IObject( IArchive & iArchive, TopFlag iFlag, const Argument &iArg0 = Argument() ) { init( iArchive, iArg0 ); } //! Default copy constructor used //! Default assignment operator used. //! Destructor //! ... virtual ~IObject(); //-************************************************************************* // OBJECT READER FUNCTIONALITY //-************************************************************************* //! All objects have a header, which contains all the MetaData that was //! specified upon their creation. //! This function returns a constant reference to that Header. const AbcA::ObjectHeader &getHeader() const; //! All objects have a name. This name is unique amongst their siblings //! Returned by reference, since it is guaranteed to exist and be //! unchanging. //! This is a convenience function which returns the header's name. const std::string &getName() const; //! The full name of an object is the complete path name all the way //! to the root object of the archive. It is guaranteed to be fully //! unique within the entire archive. //! This is a convenience function which returns the header's full name. const std::string &getFullName() const; //! All objects have metadata. This metadata is identical to the //! Metadata of the top level compoundProperty "properties". //! Because the metadata must exist and be initialized in order to //! bootstrap the object, it is guaranteed to exist and is returned //! by reference. //! This is a convenience function which returns the header's MetaData. const AbcA::MetaData &getMetaData() const { return getHeader().getMetaData(); } //! This function returns the object's archive, handily //! wrapped in an IArchive wrapper. IArchive getArchive() const; //! This function returns the object's parent, handily //! wrapped in an IObject wrapper. If the object is the top //! level object, the IObject returned will be NULL. IObject getParent() const; //! This function returns the number of child objects that //! this object has. size_t getNumChildren() const; //! This function returns the headers of each of the child //! objects that were written as children of this object. const AbcA::ObjectHeader & getChildHeader( size_t i ) const; //! Return the header of an object by name. //! This will return a NULL pointer if no header by that name is found. const AbcA::ObjectHeader * getChildHeader( const std::string &iName ) const; //! This returns the single top-level CompoundPropertyReader that exists //! automatically as part of the object. ICompoundProperty getProperties() const; //-************************************************************************* // ADVANCED TOOLS // Unless you really know why you need to be using these next few // functions, they're probably best left alone. The right way to create // an IObject is to actually call its constructor. //-************************************************************************* //! This function returns an IObject constructed from the indexed //! object. IObject getChild( size_t iChildIndex ) const; //! This function returns an IObject wrapped constructed from the //! header referenced by the name. If the child of the given name //! does not exist, this will fail in the same way as if the //! equivalent constructor was called. IObject getChild( const std::string &iChildName ) const; //!-************************************************************************ // INSTANCE METHODS // An IObject can refer to another IObject in the same cache and stand in // as an instance for that target hierarchy. On disk only the instance // object is required. When read in however, a normal hierarchy is // returned. Optionally, client code could use the isInstanceRoot() and // instanceSourcePath() methods to discover that the hierarchies are // duplicate and instance them appropriately in memory. //!-************************************************************************ //! Returns whether this object directly instances another object. bool isInstanceRoot() const; //! Returns whether this object has been arrived at via an instance, or if //! this object is an instance itself. bool isInstanceDescendant() const; //! If this object is an instance (isInstanceRoot), returns the source path //! that the instance points at. Otherwise and empty string is returned. std::string instanceSourcePath() const; bool isChildInstance(size_t iChildIndex) const; bool isChildInstance(const std::string &iChildName) const; //! Returns the original ObjectReaderPtr, if this object is an instance AbcA::ObjectReaderPtr getInstancePtr() const { return m_instanceObject; } //-************************************************************************* // ABC BASE MECHANISMS // These functions are used by Abc to deal with errors, rewrapping, // and so on. //-************************************************************************* //! getPtr, as usual, returns a shared ptr to the //! underlying AbcCoreAbstract object, in this case the //! ObjectReaderPtr. If this object happens to be an instance, it points //! to the instance source ObjectReaderPtr AbcA::ObjectReaderPtr getPtr() const { return m_object; } //! Reset returns this function set to an empty, default state. void reset(); //! Valid returns whether this function set is //! valid. bool valid() const { return ( Base::valid() && m_object ); } //! If an aggregated properties hash exists fill oDigest with it and //! return true, if it doesn't exist return false bool getPropertiesHash( Util::Digest & oDigest ); //! If an aggregated child objects hash exists fill oDigest with it and //! return true, if it doesn't exist return false bool getChildrenHash( Util::Digest & oDigest ); //! The unspecified-bool-type operator casts the object to "true" //! if it is valid, and "false" otherwise. ALEMBIC_OPERATOR_BOOL( valid() ); public: AbcA::ObjectReaderPtr m_object; private: void init( IArchive & iArchive, const Argument &iArg0 ); void init( AbcA::ObjectReaderPtr iParentObject, const std::string &iName, ErrorHandler::Policy iPolicy ); void initInstance(); void setInstancedFullName(const std::string& parentPath) const; // This is the "original" object when it is an instance (not the source) AbcA::ObjectReaderPtr m_instanceObject; // All IObject ancestors of an instance object have these set. mutable std::string m_instancedFullName; }; typedef Alembic::Util::shared_ptr< IObject > IObjectPtr; //-***************************************************************************** inline AbcA::ObjectReaderPtr GetObjectReaderPtr( IObject& iPrp ) { return iPrp.getPtr(); } //-***************************************************************************** // TEMPLATE AND INLINE FUNCTIONS //-***************************************************************************** template inline ErrorHandler::Policy GetErrorHandlerPolicy( OBJ iObj, ErrorHandler::Policy iPcy ) { Argument arg( iPcy ); return GetErrorHandlerPolicy( iObj, arg ); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/ISampleSelector.cpp000066400000000000000000000055361507001531700214630ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** index_t ISampleSelector::getIndex( const AbcA::TimeSamplingPtr & iTsmp, index_t iNumSamples ) const { index_t retIdx; if ( m_requestedIndex >= 0 ) { retIdx = m_requestedIndex; } else if ( m_requestedTimeIndexType == kNearIndex ) { retIdx = iTsmp->getNearIndex( m_requestedTime, iNumSamples ).first; } else if ( m_requestedTimeIndexType == kFloorIndex ) { retIdx = iTsmp->getFloorIndex( m_requestedTime, iNumSamples ).first; } else { assert( m_requestedTimeIndexType == kCeilIndex ); retIdx = iTsmp->getCeilIndex( m_requestedTime, iNumSamples ).first; } return retIdx < 0 ? 0 : ( retIdx < iNumSamples ? retIdx : iNumSamples-1 ); } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/ISampleSelector.h000066400000000000000000000065671507001531700211350ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_ISampleSelector_h #define Alembic_Abc_ISampleSelector_h #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** class ALEMBIC_EXPORT ISampleSelector { public: enum TimeIndexType { kFloorIndex, kCeilIndex, kNearIndex }; ISampleSelector() : m_requestedIndex( 0 ), m_requestedTime( 0.0 ), m_requestedTimeIndexType( kNearIndex ) {} ISampleSelector( index_t iReqIdx ) : m_requestedIndex( iReqIdx ), m_requestedTime( 0.0 ), m_requestedTimeIndexType( kNearIndex ) {} explicit ISampleSelector( chrono_t iReqTime, TimeIndexType iReqIdxType = kNearIndex ) : m_requestedIndex( -1 ), m_requestedTime( iReqTime ), m_requestedTimeIndexType( iReqIdxType ) {} index_t getRequestedIndex() const { return m_requestedIndex; } chrono_t getRequestedTime() const { return m_requestedTime; } TimeIndexType getRequestedTimeIndexType() const { return m_requestedTimeIndexType; } index_t getIndex( const AbcA::TimeSamplingPtr & iTsmp, index_t iNumSamples ) const; private: index_t m_requestedIndex; chrono_t m_requestedTime; TimeIndexType m_requestedTimeIndexType; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/IScalarProperty.cpp000066400000000000000000000123471507001531700215110ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { IScalarProperty::IScalarProperty( const ICompoundProperty & iParent, const std::string &iName, const Argument &iArg0 ) { init( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent ), iArg0 ); } //-***************************************************************************** IScalarProperty::~IScalarProperty() { // Nothing for now. // Mostly here in case we need to add reference-counting debug code. } //-***************************************************************************** size_t IScalarProperty::getNumSamples() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::getNumSamples()" ); return m_property->getNumSamples(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so return a default. return 0; } //-***************************************************************************** bool IScalarProperty::isConstant() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::isConstant()" ); return m_property->isConstant(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so return a default. return false; } //-***************************************************************************** AbcA::TimeSamplingPtr IScalarProperty::getTimeSampling() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::getTimeSampling()" ); return m_property->getTimeSampling(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so return a default. return AbcA::TimeSamplingPtr(); } //-***************************************************************************** void IScalarProperty::get( void *oSamp, const ISampleSelector &iSS ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::get()" ); AbcA::index_t index = iSS.getIndex( m_property->getTimeSampling(), m_property->getNumSamples() ); m_property->getSample( index, oSamp ); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** ICompoundProperty IScalarProperty::getParent() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::getParent()" ); return ICompoundProperty( m_property->getParent(), getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return ICompoundProperty(); } //-***************************************************************************** void IScalarProperty::init( AbcA::CompoundPropertyReaderPtr iParent, const std::string &iName, ErrorHandler::Policy iParentPolicy, const Argument &iArg0 ) { Arguments args( iParentPolicy ); iArg0.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::init()" ); const AbcA::PropertyHeader *pheader = iParent->getPropertyHeader( iName ); ABCA_ASSERT( pheader != NULL, "Nonexistent scalar property: " << iName ); m_property = iParent->getScalarProperty( iName ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/IScalarProperty.h000066400000000000000000000133111507001531700211460ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_IScalarProperty_h #define Alembic_Abc_IScalarProperty_h #include #include #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** class ALEMBIC_EXPORT IScalarProperty : public IBasePropertyT { public: //! By convention we always define this_type in Abc classes //! Used by unspecified-bool-type conversion below typedef IScalarProperty this_type; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty IScalarProperty function set. //! ... IScalarProperty() : IBasePropertyT() {} //! This constructor creates a new scalar property reader. //! The first argument is the parent ICompundProperty, from which the error //! handler policy for inheritance is also derived. The remaining optional //! arguments can be used to override the ErrorHandlerPolicy, and that's it. IScalarProperty( const ICompoundProperty & iParent, const std::string &iName, const Argument &iArg0 = Argument() ); //! This attaches an IScalarProperty wrapper around an existing //! ScalarPropertyReaderPtr, with an optional error handling policy. IScalarProperty( //! The pointer //! ... AbcA::ScalarPropertyReaderPtr iPtr, //! Optional error handling policy //! ... const Argument &iArg0 = Argument() ) : IBasePropertyT( iPtr, GetErrorHandlerPolicy( iPtr, iArg0 ) ) {} // Deprecated in favor of the constructor above IScalarProperty( AbcA::ScalarPropertyReaderPtr iPtr, WrapExistingFlag iWrapFlag, const Argument &iArg0 = Argument() ) : IBasePropertyT( iPtr, GetErrorHandlerPolicy( iPtr, iArg0 ) ) {} //! Default copy constructor used //! Default assignment operator used. //! Destructor //! ... ~IScalarProperty(); //-************************************************************************* // SCALAR PROPERTY READER FUNCTIONALITY //-************************************************************************* //! Return the number of samples contained in the property. //! This can be any number, including zero. //! This returns the number of samples that were written, independently //! of whether or not they were constant. size_t getNumSamples() const; //! Ask if we're constant - no change in value amongst samples, //! regardless of the time sampling. bool isConstant() const; //! Time information. //! This will be valid regardless of TimeSamplingType or number of samples. AbcA::TimeSamplingPtr getTimeSampling() const; //! Get a sample into the address of a datum. //! ... void get( void *oSample, const ISampleSelector &iSS = ISampleSelector() ) const; //! Return the parent compound property, handily wrapped in a //! ICompoundProperty wrapper. ICompoundProperty getParent() const; private: void init( AbcA::CompoundPropertyReaderPtr iParentObject, const std::string &iName, ErrorHandler::Policy iParentPolicy, const Argument &iArg0 ); }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/ISchema.h000066400000000000000000000201441507001531700173760ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_ISchema_h #define Alembic_Abc_ISchema_h #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! See Schema Notes in OSchema.h //! ... //-***************************************************************************** //-***************************************************************************** //! Usually used as a base class, but could also theoretically be used //! as a standalone template class ISchema : public ICompoundProperty { public: //-************************************************************************* // TYPEDEFS AND IDENTIFIERS //-************************************************************************* typedef INFO info_type; typedef ISchema this_type; //! Return the schema title expected of this //! property. An empty title matches everything static const char * getSchemaTitle() { return INFO::title(); } //! Return the default name for instances of this schema. Often //! something like ".geom" static const char * getDefaultSchemaName() { return INFO::defaultName(); } //! This will check whether or not a given entity (as represented by //! a metadata) strictly matches the interpretation of this //! schema object static bool matches( const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching = kStrictMatching ) { if ( std::string() == getSchemaTitle() || iMatching == kNoMatching ) { return true; } if ( iMatching == kStrictMatching || iMatching == kSchemaTitleMatching ) { return iMetaData.get( "schema" ) == getSchemaTitle(); } return false; } //! This will check whether or not a given object (as represented by //! an object header) strictly matches the interpretation of this //! schema object, as well as the data type. static bool matches( const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching = kStrictMatching ) { return matches( iHeader.getMetaData(), iMatching ); } //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty ISchema //! function set. ISchema() {} //! Creates a new Compound Property Reader with the schema //! information added to the metadata. //! arguments count include error handling, strictness matching. ISchema( const ICompoundProperty &iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) { init( iParent, iName, iArg0, iArg1 ); } //! Wrap an existing compound property, checking that it matches //! the schema title info, if strict matching has been selected. //! Arguments allow selection of error handling and matching strictness ISchema( const ICompoundProperty &iProperty, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) : ICompoundProperty( iProperty.getPtr(), GetErrorHandlerPolicy( iProperty, iArg0, iArg1 ) ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ISchema::ISchema( wrap )" ); const AbcA::PropertyHeader &pheader = this->getHeader(); ABCA_ASSERT( matches( pheader, GetSchemaInterpMatching( iArg0, iArg1 ) ), "Incorrect match of schema: " << pheader.getMetaData().get( "schema" ) << " to expected: " << INFO::title() ); // not wrapped, we want to use the default name if ( !iProperty.getParent().valid() ) { init( iProperty, getDefaultSchemaName(), iArg0, iArg1 ); } ALEMBIC_ABC_SAFE_CALL_END_RESET(); } // Deprecated in favor of the constructor above ISchema( const ICompoundProperty &iProperty, WrapExistingFlag iFlag, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) { *this = ISchema( iProperty, iArg0, iArg1 ); } //! Default copy constructor used //! Default assignment operator used. // virtual ~ISchema() {} private: void init( const ICompoundProperty & iParentObject, const std::string &iName, const Argument &iArg0, const Argument &iArg1 ); }; //-***************************************************************************** // TEMPLATE AND INLINE FUNCTIONS //-***************************************************************************** template void ISchema::init( const ICompoundProperty & iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1 ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "ISchema::ISchema::init()" ); // Get actual reader for parent. ABCA_ASSERT( iParent, "NULL parent passed into ISchema ctor" ); AbcA::CompoundPropertyReaderPtr parent = iParent.getPtr(); ABCA_ASSERT( parent, "NULL CompoundPropertyReaderPtr" ); const AbcA::PropertyHeader *pheader = parent->getPropertyHeader( iName ); ABCA_ASSERT( pheader != NULL, "Nonexistent compound property: " << iName ); // Check metadata for schema. ABCA_ASSERT( matches( *pheader, args.getSchemaInterpMatching() ), "Incorrect match of schema: " << pheader->getMetaData().get( "schema" ) << " to expected: " << INFO::title() ); // Get property. m_property = parent->getCompoundProperty( iName ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/ISchemaObject.h000066400000000000000000000234161507001531700205320ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_ISchemaObject_h #define Alembic_Abc_ISchemaObject_h #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! An ISchemaObject is an object with a single schema. This is just //! a convenience class, really, but it also deals with setting up and //! validating metadata template class ISchemaObject : public IObject { public: //-************************************************************************* // TYPEDEFS AND IDENTIFIERS //-************************************************************************* typedef SCHEMA schema_type; typedef ISchemaObject this_type; //! Our schema title contains the schema title of the underlying //! compound property, along with the default name of that compound //! property. So, for example - most AbcGeom types put their //! data in ".geom", so, "AbcGeom_PolyMesh_v1:.geom" //! Sometimes schema titles from underlying schemas are "", but //! ours never are. static std::string getSchemaObjTitle() { return SCHEMA::getSchemaTitle() + std::string( ":" ) + SCHEMA::getDefaultSchemaName(); } static const char * getSchemaTitle() { return SCHEMA::getSchemaTitle(); } //! This will check whether or not a given entity (as represented by //! a metadata) strictly matches the interpretation of this //! schema object static bool matches( const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching = kStrictMatching ) { if ( std::string() == getSchemaTitle() || iMatching == kNoMatching ) { return true; } if ( iMatching == kStrictMatching ) { return iMetaData.get( "schemaObjTitle" ) == getSchemaObjTitle() || iMetaData.get( "schema" ) == getSchemaObjTitle(); } if ( iMatching == kSchemaTitleMatching ) { return iMetaData.get( "schema" ) == getSchemaTitle(); } return false; } //! This will check whether or not a given object (as represented by //! an object header) strictly matches the interpretation of this //! schema object, as well as the data type. static bool matches( const AbcA::ObjectHeader &iHeader, SchemaInterpMatching iMatching = kStrictMatching ) { return matches( iHeader.getMetaData(), iMatching ); } //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty ISchemaObject function set. //! ... ISchemaObject() {} //! The primary constructor creates an ISchemaObject as a child of iParent ISchemaObject( const IObject & iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) : IObject( iParent, iName, GetErrorHandlerPolicyFromArgs( iArg0, iArg1 ) ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "ISchemaObject::ISchemaObject( IObject )" ); const AbcA::ObjectHeader &oheader = this->getHeader(); ABCA_ASSERT( matches( oheader, args.getSchemaInterpMatching() ), "Incorrect match of schema: " << oheader.getMetaData().get( "schema" ) << " to expected: " << getSchemaTitle() ); ABCA_ASSERT(m_object, "Bad child: " << iName); // Make the schema. m_schema = SCHEMA( m_object->getProperties(), SCHEMA::getDefaultSchemaName(), this->getErrorHandlerPolicy(), args.getSchemaInterpMatching() ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } //! Wrap an existing schema object. //! ... ISchemaObject( const IObject & iObject, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) : IObject( iObject ) { getErrorHandler().setPolicy( GetErrorHandlerPolicy( iObject, iArg0, iArg1 ) ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "ISchemaObject::ISchemaObject( wrap )" ); const AbcA::ObjectHeader &oheader = this->getHeader(); ABCA_ASSERT( matches( oheader.getMetaData(), GetSchemaInterpMatching( iArg0, iArg1 ) ), "Incorrect match of schema: " << oheader.getMetaData().get( "schemaObjTitle" ) << " to expected: " << getSchemaObjTitle() ); m_schema = SCHEMA( this->getProperties(), SCHEMA::getDefaultSchemaName(), this->getErrorHandlerPolicy(), GetSchemaInterpMatching( iArg0, iArg1 ) ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } // Deprecated in favor of the constructor above ISchemaObject( const IObject & iObject, WrapExistingFlag iFlag, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) : IObject( iObject ) { getErrorHandler().setPolicy( GetErrorHandlerPolicy( iObject, iArg0, iArg1 ) ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "ISchemaObject::ISchemaObject( wrapflag )" ); const AbcA::ObjectHeader &oheader = this->getHeader(); ABCA_ASSERT( matches( oheader.getMetaData(), GetSchemaInterpMatching( iArg0, iArg1 ) ), "Incorrect match of schema: " << oheader.getMetaData().get( "schemaObjTitle" ) << " to expected: " << getSchemaObjTitle() ); m_schema = SCHEMA( this->getProperties(), SCHEMA::getDefaultSchemaName(), this->getErrorHandlerPolicy(), GetSchemaInterpMatching( iArg0, iArg1 ) ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } //-************************************************************************* // ABC BASE MECHANISMS // These functions are used by Abc to deal with errors, rewrapping, // and so on. //-************************************************************************* //! Schemas are not necessarily cheap to copy, so we return by reference //! rather than by value. SCHEMA &getSchema() { return m_schema; } const SCHEMA &getSchema() const { return m_schema; } //! Reset returns this function set to an empty, default //! state. void reset() { m_schema.reset(); IObject::reset(); } //! Valid returns whether this function set is //! valid. bool valid() const { return ( IObject::valid() && m_schema.valid() ); } //! The unspecified-bool-type operator casts the object to "true" //! if it is valid, and "false" otherwise. ALEMBIC_OVERRIDE_OPERATOR_BOOL( this_type::valid() ); protected: SCHEMA m_schema; }; //-***************************************************************************** // TEMPLATE AND INLINE FUNCTIONS //-***************************************************************************** inline ErrorHandler::Policy GetErrorHandlerPolicy( const Argument &iArg0, const Argument &iArg1 ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); return args.getErrorHandlerPolicy(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/ITypedArrayProperty.h000066400000000000000000000312461507001531700220340ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_ITypedArrayProperty_h #define Alembic_Abc_ITypedArrayProperty_h #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** template class ITypedArrayProperty : public IArrayProperty { public: //-************************************************************************* // TYPEDEFS AND IDENTIFIERS //-************************************************************************* typedef TRAITS traits_type; typedef ITypedArrayProperty this_type; typedef typename TRAITS::value_type value_type; typedef TypedArraySample sample_type; typedef shared_ptr sample_ptr_type; //! Return the interpretation expected of this //! property. An empty interpretation matches everything static const char * getInterpretation() { return TRAITS::interpretation(); } //! This will check whether or not a given entity (as represented by //! a metadata) strictly matches the interpretation of this //! schema object static bool matches( const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching = kStrictMatching ) { if ( iMatching == kStrictMatching ) { return ( iMetaData.get( "interpretation" ) == getInterpretation() ); } return true; } //! This will check whether or not a given object (as represented by //! an object header) strictly matches the interpretation of this //! schema object static bool matches( const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching = kStrictMatching ) { return ( iHeader.getDataType().getPod() == TRAITS::dataType().getPod() && ( iHeader.getDataType().getExtent() == TRAITS::dataType().getExtent() || std::string() == getInterpretation() ) ) && iHeader.isArray() && matches( iHeader.getMetaData(), iMatching ); } //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! Default constructor //! ... ITypedArrayProperty() {} //! This constructor creates a new typed array property reader. //! The first argument is the ICompoundProperty parent, from which the //! error handler policy for inheritance is also derived. The remaining //! optional arguments can be used to override the ErrorHandlerPolicy, //! to specify schema matching policy, and that's it. ITypedArrayProperty( const ICompoundProperty &iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) { Arguments args( GetErrorHandlerPolicy( iParent ) ); iArg0.setInto( args ); iArg1.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "ITypedArrayProperty::ITypedArrayProperty()" ); AbcA::CompoundPropertyReaderPtr parent = iParent.getPtr(); ABCA_ASSERT( parent != NULL, "NULL CompoundPropertyReader passed into " << "ITypedArrayProperty ctor" ); const AbcA::PropertyHeader *pheader = parent->getPropertyHeader( iName ); ABCA_ASSERT( pheader != NULL, "Nonexistent array property: " << iName ); ABCA_ASSERT( matches( *pheader, args.getSchemaInterpMatching() ), "Incorrect match of header datatype: " << pheader->getDataType() << " to expected: " << TRAITS::dataType() << ",\n...or incorrect match of interpretation: " << pheader->getMetaData().get( "interpretation" ) << " to expected: " << TRAITS::interpretation() ); m_property = parent->getArrayProperty( iName ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } //! Explicitly wrap an existing property //! It will check the data type and also verify the schema, //! if requested. ITypedArrayProperty( AbcA::ArrayPropertyReaderPtr iProperty, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ITypedArrayProperty::ITypedArrayProperty()" ); const AbcA::PropertyHeader &pheader = iProperty->getHeader(); ABCA_ASSERT( matches( pheader,GetSchemaInterpMatching( iArg0, iArg1 ) ), "Incorrect match of header datatype: " << pheader.getDataType() << " to expected: " << TRAITS::dataType() << ",\n...or incorrect match of interpretation: " << pheader.getMetaData().get( "interpretation" ) << " to expected: " << TRAITS::interpretation() ); m_property = iProperty; ALEMBIC_ABC_SAFE_CALL_END_RESET(); } // Deprecated in favor of the constructor above ITypedArrayProperty( AbcA::ArrayPropertyReaderPtr iProp, WrapExistingFlag iWrapFlag, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) { *this = ITypedArrayProperty( iProp, iArg0, iArg1 ); } //-************************************************************************* // ARRAY PROPERTY FEATURES //-************************************************************************* //! Get the typed sample. //! ... void get( sample_ptr_type& iVal, const ISampleSelector &iSS = ISampleSelector() ) const { AbcA::ArraySamplePtr ptr; IArrayProperty::get( ptr, iSS ); iVal = Alembic::Util::static_pointer_cast( ptr ); } //! Return the typed sample by value. //! ... sample_ptr_type getValue( const ISampleSelector &iSS = ISampleSelector() ) const { sample_ptr_type ret; get( ret, iSS ); return ret; } }; //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** typedef ITypedArrayProperty IBoolArrayProperty; typedef ITypedArrayProperty IUcharArrayProperty; typedef ITypedArrayProperty ICharArrayProperty; typedef ITypedArrayProperty IUInt16ArrayProperty; typedef ITypedArrayProperty IInt16ArrayProperty; typedef ITypedArrayProperty IUInt32ArrayProperty; typedef ITypedArrayProperty IInt32ArrayProperty; typedef ITypedArrayProperty IUInt64ArrayProperty; typedef ITypedArrayProperty IInt64ArrayProperty; typedef ITypedArrayProperty IHalfArrayProperty; typedef ITypedArrayProperty IFloatArrayProperty; typedef ITypedArrayProperty IDoubleArrayProperty; typedef ITypedArrayProperty IStringArrayProperty; typedef ITypedArrayProperty IWstringArrayProperty; typedef ITypedArrayProperty IV2sArrayProperty; typedef ITypedArrayProperty IV2iArrayProperty; typedef ITypedArrayProperty IV2fArrayProperty; typedef ITypedArrayProperty IV2dArrayProperty; typedef ITypedArrayProperty IV3sArrayProperty; typedef ITypedArrayProperty IV3iArrayProperty; typedef ITypedArrayProperty IV3fArrayProperty; typedef ITypedArrayProperty IV3dArrayProperty; typedef ITypedArrayProperty IP2sArrayProperty; typedef ITypedArrayProperty IP2iArrayProperty; typedef ITypedArrayProperty IP2fArrayProperty; typedef ITypedArrayProperty IP2dArrayProperty; typedef ITypedArrayProperty IP3sArrayProperty; typedef ITypedArrayProperty IP3iArrayProperty; typedef ITypedArrayProperty IP3fArrayProperty; typedef ITypedArrayProperty IP3dArrayProperty; typedef ITypedArrayProperty IBox2sArrayProperty; typedef ITypedArrayProperty IBox2iArrayProperty; typedef ITypedArrayProperty IBox2fArrayProperty; typedef ITypedArrayProperty IBox2dArrayProperty; typedef ITypedArrayProperty IBox3sArrayProperty; typedef ITypedArrayProperty IBox3iArrayProperty; typedef ITypedArrayProperty IBox3fArrayProperty; typedef ITypedArrayProperty IBox3dArrayProperty; typedef ITypedArrayProperty IM33fArrayProperty; typedef ITypedArrayProperty IM33dArrayProperty; typedef ITypedArrayProperty IM44fArrayProperty; typedef ITypedArrayProperty IM44dArrayProperty; typedef ITypedArrayProperty IQuatfArrayProperty; typedef ITypedArrayProperty IQuatdArrayProperty; typedef ITypedArrayProperty IC3hArrayProperty; typedef ITypedArrayProperty IC3fArrayProperty; typedef ITypedArrayProperty IC3cArrayProperty; typedef ITypedArrayProperty IC4hArrayProperty; typedef ITypedArrayProperty IC4fArrayProperty; typedef ITypedArrayProperty IC4cArrayProperty; typedef ITypedArrayProperty IN2fArrayProperty; typedef ITypedArrayProperty IN2dArrayProperty; typedef ITypedArrayProperty IN3fArrayProperty; typedef ITypedArrayProperty IN3dArrayProperty; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/ITypedScalarProperty.h000066400000000000000000000277561507001531700221760ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_ITypedScalarProperty_h #define Alembic_Abc_ITypedScalarProperty_h #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** template class ITypedScalarProperty : public IScalarProperty { public: //-************************************************************************* // TYPEDEFS AND IDENTIFIERS //-************************************************************************* typedef TRAITS traits_type; typedef ITypedScalarProperty this_type; typedef typename TRAITS::value_type value_type; //! Return the interpretation expected of this //! property. An empty interpretation matches everything static const char * getInterpretation() { return TRAITS::interpretation(); } //! This will check whether or not a given entity (as represented by //! a metadata) strictly matches the interpretation of this //! schema object static bool matches( const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching = kStrictMatching ) { if ( iMatching == kStrictMatching ) { return ( iMetaData.get( "interpretation" ) == getInterpretation() ); } return true; } //! This will check whether or not a given object (as represented by //! an object header) strictly matches the interpretation of this //! schema object static bool matches( const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching = kStrictMatching ) { return ( iHeader.getDataType().getPod() == TRAITS::dataType().getPod() && iHeader.getDataType().getExtent() == TRAITS::dataType().getExtent() && iHeader.isScalar() && matches( iHeader.getMetaData(), iMatching ) ); } //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! Default constructor //! ... ITypedScalarProperty() {} //! This constructor creates a new typed scalar property reader. //! The first argument is the ICompoundProperty parent, from which the //! error handler policy for inheritance is also derived. The remaining //! optional arguments can be used to override the ErrorHandlerPolicy, //! to specify schema matching policy, and that's it. ITypedScalarProperty( const ICompoundProperty & iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) { Arguments args( GetErrorHandlerPolicy( iParent ) ); iArg0.setInto( args ); iArg1.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "ITypedScalarProperty::ITypedScalarProperty()" ); AbcA::CompoundPropertyReaderPtr parent = iParent.getPtr(); ABCA_ASSERT( parent != NULL, "NULL CompoundPropertyReader passed into " << "ITypedScalarProperty ctor" ); const AbcA::PropertyHeader *pheader = parent->getPropertyHeader( iName ); ABCA_ASSERT( pheader != NULL, "Nonexistent scalar property: " << iName ); ABCA_ASSERT( matches( *pheader, args.getSchemaInterpMatching() ), "Incorrect match of header datatype: " << pheader->getDataType() << " to expected: " << TRAITS::dataType() << ",\n...or incorrect match of interpretation: " << pheader->getMetaData().get( "interpretation" ) << " to expected: " << TRAITS::interpretation() ); m_property = parent->getScalarProperty( iName ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } //! Explicitly wrap an existing property //! It will check the data type and also verify the schema, //! if requested. ITypedScalarProperty( AbcA::ScalarPropertyReaderPtr iProperty, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ITypedScalarProperty::ITypedScalarProperty()" ); const AbcA::PropertyHeader &pheader = iProperty->getHeader(); ABCA_ASSERT( matches( pheader, GetSchemaInterpMatching( iArg0, iArg1 ) ), "Incorrect match of header datatype: " << pheader.getDataType() << " to expected: " << TRAITS::dataType() << ",\n...or incorrect match of interpretation: " << pheader.getMetaData().get( "interpretation" ) << " to expected: " << TRAITS::interpretation() ); m_property = iProperty; ALEMBIC_ABC_SAFE_CALL_END_RESET(); } //! Deprecated in favor of the constructor above ITypedScalarProperty( AbcA::ScalarPropertyReaderPtr iProp, WrapExistingFlag iWrapFlag, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) { *this = ITypedScalarProperty( iProp, iArg0, iArg1 ); } //-************************************************************************* // SCALAR PROPERTY FEATURES //-************************************************************************* //! Get the typed sample. //! ... void get( value_type &iVal, const ISampleSelector &iSS = ISampleSelector() ) const { IScalarProperty::get( reinterpret_cast( &iVal ), iSS ); } //! Return the typed sample by value. //! ... value_type getValue( const ISampleSelector &iSS = ISampleSelector() ) const { value_type ret; get( ret, iSS ); return ret; } }; //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** typedef ITypedScalarProperty IBoolProperty; typedef ITypedScalarProperty IUcharProperty; typedef ITypedScalarProperty ICharProperty; typedef ITypedScalarProperty IUInt16Property; typedef ITypedScalarProperty IInt16Property; typedef ITypedScalarProperty IUInt32Property; typedef ITypedScalarProperty IInt32Property; typedef ITypedScalarProperty IUInt64Property; typedef ITypedScalarProperty IInt64Property; typedef ITypedScalarProperty IHalfProperty; typedef ITypedScalarProperty IFloatProperty; typedef ITypedScalarProperty IDoubleProperty; typedef ITypedScalarProperty IStringProperty; typedef ITypedScalarProperty IWstringProperty; typedef ITypedScalarProperty IV2sProperty; typedef ITypedScalarProperty IV2iProperty; typedef ITypedScalarProperty IV2fProperty; typedef ITypedScalarProperty IV2dProperty; typedef ITypedScalarProperty IV3sProperty; typedef ITypedScalarProperty IV3iProperty; typedef ITypedScalarProperty IV3fProperty; typedef ITypedScalarProperty IV3dProperty; typedef ITypedScalarProperty IP2sProperty; typedef ITypedScalarProperty IP2iProperty; typedef ITypedScalarProperty IP2fProperty; typedef ITypedScalarProperty IP2dProperty; typedef ITypedScalarProperty IP3sProperty; typedef ITypedScalarProperty IP3iProperty; typedef ITypedScalarProperty IP3fProperty; typedef ITypedScalarProperty IP3dProperty; typedef ITypedScalarProperty IBox2sProperty; typedef ITypedScalarProperty IBox2iProperty; typedef ITypedScalarProperty IBox2fProperty; typedef ITypedScalarProperty IBox2dProperty; typedef ITypedScalarProperty IBox3sProperty; typedef ITypedScalarProperty IBox3iProperty; typedef ITypedScalarProperty IBox3fProperty; typedef ITypedScalarProperty IBox3dProperty; typedef ITypedScalarProperty IM33fProperty; typedef ITypedScalarProperty IM33dProperty; typedef ITypedScalarProperty IM44fProperty; typedef ITypedScalarProperty IM44dProperty; typedef ITypedScalarProperty IQuatfProperty; typedef ITypedScalarProperty IQuatdProperty; typedef ITypedScalarProperty IC3hProperty; typedef ITypedScalarProperty IC3fProperty; typedef ITypedScalarProperty IC3cProperty; typedef ITypedScalarProperty IC4hProperty; typedef ITypedScalarProperty IC4fProperty; typedef ITypedScalarProperty IC4cProperty; typedef ITypedScalarProperty IN2fProperty; typedef ITypedScalarProperty IN2dProperty; typedef ITypedScalarProperty IN3fProperty; typedef ITypedScalarProperty IN3dProperty; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/OArchive.cpp000066400000000000000000000115651507001531700201270ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** // This is mostly here to provide debug support when tracing down // bad reference counting. OArchive::~OArchive() { //std::cout << "OArchive::~OArchive() name: " // << this->getName() << std::endl // << "\tTop Object use count: " << m_topObject.use_count() // << std::endl; } //-***************************************************************************** std::string OArchive::getName() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArchive::getName()" ); return m_archive->getName(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, // so return a NO-OP value return ""; } //-***************************************************************************** int8_t OArchive::getCompressionHint() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArchive::getCompressionHint" ); return m_archive->getCompressionHint(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, // so return a NO-OP value return -1; } //-***************************************************************************** void OArchive::setCompressionHint( int8_t iCh ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArchive::setCompressionHint" ); m_archive->setCompressionHint( iCh ); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** uint32_t OArchive::addTimeSampling( const AbcA::TimeSampling & iTs ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArchive::addTimeSampling" ); return m_archive->addTimeSampling( iTs ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, // so return a NO-OP value return 0; } //-***************************************************************************** AbcA::TimeSamplingPtr OArchive::getTimeSampling( uint32_t iIndex ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArchive::getTimeSampling" ); return m_archive->getTimeSampling( iIndex ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, // so return a NO-OP value return AbcA::TimeSamplingPtr(); } //-***************************************************************************** uint32_t OArchive::getNumTimeSamplings() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArchive::getNumTimeSampling" ); return m_archive->getNumTimeSamplings( ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, // so return a NO-OP value return 0; } //-***************************************************************************** OObject OArchive::getTop() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArchive::getTop()" ); return OObject( m_archive->getTop() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so here is a default behavior. return OObject(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/OArchive.h000066400000000000000000000200061507001531700175620ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_OArchive_h #define Alembic_Abc_OArchive_h #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { class OObject; //-***************************************************************************** class ALEMBIC_EXPORT OArchive : public Base { public: //! By convention, we always define "this_type" in every Abc //! class. This convention is relied upon by the unspecified-bool-type //! conversion. typedef OArchive this_type; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty OArchive function set. //! ... OArchive() {} //! The explicit constructor creates an archive with the given //! file name. Additional arguments that may be passed are the //! error handling policy and meta data. template OArchive( //! We need to pass in a constructor which provides //! an explicit link to the concrete implementation of //! AbcCoreAbstract that we're using. ARCHIVE_CTOR iCtor, //! File name const std::string &iFileName, //! Optionally could be the error handling policy, or the meta data. const Argument &iArg0 = Argument(), //! Optionally could be the error handling policy, or the meta data. const Argument &iArg1 = Argument() ); //! This attaches an OArchive wrapper around an existing //! ArchiveWriterPtr, with an optional error handling policy. OArchive( //! The pointer //! ... AbcA::ArchiveWriterPtr iPtr, //! Optional error handling policy //! ... ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy ) : m_archive( iPtr ) { // Set the error handling policy. getErrorHandler().setPolicy( iPolicy ); } // Deprecated in favor of the constructor above OArchive( AbcA::ArchiveWriterPtr iPtr, WrapExistingFlag /* iWrap */, ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy ) : m_archive( iPtr ) { // Set the error handling policy. getErrorHandler().setPolicy( iPolicy ); } //! Destructor //! ... ~OArchive(); //! Default copy constructor //! Default assignment operator //-************************************************************************* // ARCHIVE WRITER FUNCTIONALITY //-************************************************************************* //! Returns the file name. //! It is an error to do so with an invalid object. std::string getName() const; //! This returns the single top-level OObject that exists //! automatically as part of the archive. OObject getTop(); //! Get the compression applied to array properties. //! The value will be -1 for uncompressed, and 0-9 for weak through //! strong gzip compression. int8_t getCompressionHint() const; //! Set the compression applied to array properties. //! Value of -1 means uncompressed, and values of 0-9 indicate increasingly //! compressed data, at the expense of time. void setCompressionHint( int8_t iCh ); //! Adds the TimeSampling to the Archive TimeSampling pool. //! If the TimeSampling already exists in the pool, the index for the match //! should be returned. //! index 0 is automatically reserved for uniform time sampling with a start //! time of 0 and time per cycle of 1 (aka identity sampling) uint32_t addTimeSampling( const AbcA::TimeSampling & iTs ); //! Returns the TimeSampling at a given index. //! index 0 is automatically reserved for uniform time sampling with a start //! time of 0 and time per cycle of 1 (aka identity sampling) AbcA::TimeSamplingPtr getTimeSampling( uint32_t iIndex ); //! Returns the total number of TimeSamplingPtrs in the Archive //! TimeSampling pool. uint32_t getNumTimeSamplings(); //-************************************************************************* // ABC BASE MECHANISMS // These functions are used by Abc to deal with errors, rewrapping, // and so on. //-************************************************************************* //! getPtr, as usual, returns a shared ptr to the //! underlying AbcCoreAbstract object, in this case the //! ArchiveWriterPtr. AbcA::ArchiveWriterPtr getPtr() { return m_archive; } //! Reset returns this function set to an empty, default //! state. void reset() { m_archive.reset(); Base::reset(); } //! Valid returns whether this function set is //! valid. bool valid() const { return ( Base::valid() && m_archive ); } //! The unspecified-bool-type operator casts the object to "true" //! if it is valid, and "false" otherwise. ALEMBIC_OPERATOR_BOOL( valid() ); private: AbcA::ArchiveWriterPtr m_archive; }; //-***************************************************************************** inline AbcA::ArchiveWriterPtr GetArchiveWriterPtr( OArchive &iArch ) { return iArch.getPtr(); } //-***************************************************************************** //-***************************************************************************** template OArchive::OArchive( ARCHIVE_CTOR iCtor, const std::string &iFileName, const Argument &iArg0, const Argument &iArg1 ) { // Create arguments Arguments args( ErrorHandler::kThrowPolicy ); iArg0.setInto( args ); iArg1.setInto( args ); // Set the error handling policy. getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArchive::OArchive( iFileName )" ); m_archive = iCtor( iFileName, args.getMetaData() ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/OArrayProperty.cpp000066400000000000000000000135131507001531700213640ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** OArrayProperty::OArrayProperty( OCompoundProperty iParent, const std::string &iName, const AbcA::DataType &iDataType, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 ) { init( iParent.getPtr(), iName, iDataType, GetErrorHandlerPolicy( iParent ), iArg0, iArg1, iArg2 ); } //-***************************************************************************** OArrayProperty::~OArrayProperty() { // Nothing for now. // Mostly here in case we need to add reference-counting debug code. } //-***************************************************************************** size_t OArrayProperty::getNumSamples() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArrayProperty::getNumSamples()" ); return m_property->getNumSamples(); ALEMBIC_ABC_SAFE_CALL_END(); return 0; } //-***************************************************************************** void OArrayProperty::set( const AbcA::ArraySample &iSamp ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArrayProperty::set()" ); m_property->setSample( iSamp ); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** void OArrayProperty::setFromPrevious() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArrayProperty::setFromPrevious()" ); m_property->setFromPreviousSample(); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** void OArrayProperty::setTimeSampling( uint32_t iIndex ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArrayProperty::setTimeSampling(uint32_t)" ); m_property->setTimeSamplingIndex(iIndex); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** void OArrayProperty::setTimeSampling( AbcA::TimeSamplingPtr iTime ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArrayProperty::setTimeSampling()" ); uint32_t tsIndex = m_property->getParent()->getObject()->getArchive()->addTimeSampling( *iTime); m_property->setTimeSamplingIndex(tsIndex); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** OCompoundProperty OArrayProperty::getParent() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArrayProperty::getParent()" ); return OCompoundProperty( m_property->getParent(), getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return OCompoundProperty(); } //-***************************************************************************** void OArrayProperty::init( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const AbcA::DataType &iDataType, ErrorHandler::Policy iParentPolicy, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 ) { Arguments args( iParentPolicy ); iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArrayProperty::init()" ); AbcA::TimeSamplingPtr tsPtr = args.getTimeSampling(); uint32_t tsIndex = args.getTimeSamplingIndex(); // if we specified a valid TimeSamplingPtr, use it to determine the index // otherwise we'll use the index, which defaults to the intrinsic 0 index if (tsPtr) { tsIndex = iParent->getObject()->getArchive()->addTimeSampling(*tsPtr); } m_property = iParent->createArrayProperty( iName, args.getMetaData(), iDataType, tsIndex ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/OArrayProperty.h000066400000000000000000000140261507001531700210310ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_OArrayProperty_h #define Alembic_Abc_OArrayProperty_h #include #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** class ALEMBIC_EXPORT OArrayProperty : public OBasePropertyT { public: //! By convention we always define this_type in Abc classes //! Used by unspecified-bool-type conversion below typedef OArrayProperty this_type; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty OArrayProperty function set. //! ... OArrayProperty() : OBasePropertyT() {} //! Create a new OArrayProperty named iName as a child of compound iParent, //! of data type iDataType. The remaining optional arguments can be used //! to override the ErrorHandlerPolicy, specify MetaData, //! and to specify time sampling or time sampling index. OArrayProperty( OCompoundProperty iParent, const std::string &iName, const AbcA::DataType &iDataType, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument() ); //! This attaches an OArrayProperty wrapper around an existing //! ArrayPropertyWriterPtr, with an optional error handling policy. OArrayProperty( AbcA::ArrayPropertyWriterPtr iPtr, const Argument &iArg0 = Argument() ) : OBasePropertyT( iPtr, GetErrorHandlerPolicy( iPtr, iArg0 ) ) {} // Deprecated in favor of the constructor above OArrayProperty( AbcA::ArrayPropertyWriterPtr iPtr, WrapExistingFlag iWrapFlag, const Argument &iArg0 = Argument() ) : OBasePropertyT( iPtr, GetErrorHandlerPolicy( iPtr, iArg0 ) ) {} //! Default copy constructor used //! Default assignment operator used. //! Destructor //! ... ~OArrayProperty(); //-************************************************************************* // ARRAY PROPERTY WRITER FUNCTIONALITY //-************************************************************************* //! Get the number of samples written so far. //! May change over time as more samples are written. size_t getNumSamples() const; //! Set a sample from the address of a datum. //! ... void set( const AbcA::ArraySample &iSample ); //! Set a sample from the previous sample. //! ... void setFromPrevious( ); //! Changes the TimeSampling used by this property. //! If the TimeSampling is changed to Acyclic and the number of samples //! currently set is more than the number of times provided in the Acyclic //! TimeSampling, an exception will be thrown. void setTimeSampling( uint32_t iIndex ); //! Changes the TimeSampling used by this property. //! If the TimeSampling is changed to Acyclic and the number of samples //! currently set is more than the number of times provided in the Acyclic //! TimeSampling, an exception will be thrown. void setTimeSampling( AbcA::TimeSamplingPtr iTime ); //! Return the parent compound property, handily wrapped in a //! OCompoundProperty wrapper. OCompoundProperty getParent() const; private: void init( AbcA::CompoundPropertyWriterPtr iParentObject, const std::string &iName, const AbcA::DataType &iDataType, ErrorHandler::Policy iParentPolicy, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 ); }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/OBaseProperty.h000066400000000000000000000213661507001531700206320ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_OBaseProperty_h #define Alembic_Abc_OBaseProperty_h #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! Most of the functionality of properties (getting information about the //! properties and so on) is common to all property types, so we create //! a base class to contain all that functionality. //! This is purely a base class for other properties to derive from, //! it will never be created directly. template class OBasePropertyT : public Base { public: //! By convention we always define this_type in Abc classes //! Used by unspecified-bool-type conversion below typedef OBasePropertyT this_type; typedef OBasePropertyT operator_bool_base_type; protected: friend class OCompoundProperty; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty OBaseProperty function set. //! ... OBasePropertyT() {} //! This attaches an OBaseProperty wrapper around an existing //! PROP_PTR, with the given error handler policy OBasePropertyT( //! The pointer //! ... PROP_PTR iPtr, //! The error handling. //! ... ErrorHandler::Policy iPolicy ); //! Default copy constructor used //! Default assignment operator used. public: //-************************************************************************* // PROPERTY WRITER FUNCTIONALITY //-************************************************************************* //! Return the property's header. //! ... const AbcA::PropertyHeader & getHeader() const; //! This function returns the property's local name //! ... const std::string &getName() const { return getHeader().getName(); } //! This function returns the property's type //! ... AbcA::PropertyType getPropertyType() const { return getHeader().getPropertyType(); } //! Convenience to return whether the property is scalar. //! Same as getPropertyType() == kScalarProperty bool isScalar() const { return getPropertyType() == AbcA::kScalarProperty; } //! Convenience to return whether the property is array. //! Same as getPropertyType() == kArrayProperty bool isArray() const { return getPropertyType() == AbcA::kArrayProperty; } //! Convenience to return whether the property is compound. //! Same as getPropertyType() == kCompoundProperty bool isCompound() const { return getPropertyType() == AbcA::kCompoundProperty; } //! Convenience to return whether the property is simple (non-compound) //! Same as getPropertyType() != kCompoundProperty bool isSimple() const { return !isCompound(); } //! All properties have MetaData. This just returns the //! MetaData portion of the header that was used in creation. const AbcA::MetaData &getMetaData() const { return getHeader().getMetaData(); } //! Non-compound properties have a DataType. It is an error //! to call this function for CompoundProperties, and an exception will //! be thrown. This is a convenience function which just returns the //! DataType from the header that was used in creation. const AbcA::DataType &getDataType() const { return getHeader().getDataType(); } //! Non-compound properties have a TimeSamplingPtr. It is an error //! to call this function for CompoundProperties, and an exception will //! be thrown. This is a convenience function which just returns the //! TimeSamplingPtr from the header that was used in creation. AbcA::TimeSamplingPtr getTimeSampling() const { return getHeader().getTimeSampling(); } //! This function returns the property's object, handily //! wrapped in an OObject wrapper. OObject getObject() const; //! Can't wrap //! OCompoundProperty getParent(); //-************************************************************************* // ABC BASE MECHANISMS // These functions are used by Abc to deal with errors, rewrapping, // and so on. //-************************************************************************* //! getPtr, as usual, returns a shared ptr to the //! underlying AbcCoreAbstract object, in this case the //! PROP_PTR. PROP_PTR getPtr() const { return m_property; } //! Reset returns this function set to an empty, default //! state. void reset() { m_property.reset(); Base::reset(); } //! Valid returns whether this function set is //! valid. bool valid() const { return ( Base::valid() && m_property ); } //! The unspecified-bool-type operator casts the object to "true" //! if it is valid, and "false" otherwise. ALEMBIC_OPERATOR_BOOL( valid() ); protected: PROP_PTR m_property; }; //-***************************************************************************** typedef OBasePropertyT OBaseProperty; //-***************************************************************************** // TEMPLATE AND INLINE FUNCTIONS //-***************************************************************************** //-***************************************************************************** template inline OBasePropertyT::OBasePropertyT ( PROP_PTR iPtr, ErrorHandler::Policy iPolicy ) : m_property( iPtr ) { getErrorHandler().setPolicy( iPolicy ); } namespace { const AbcA::PropertyHeader g_phd; } //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** template const AbcA::PropertyHeader &OBasePropertyT::getHeader() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OBaseProperty::getHeader()" ); return m_property->getHeader(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so have a default behavior. return g_phd; }; //-***************************************************************************** template OObject OBasePropertyT::getObject() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OBaseProperty::getObject()" ); return OObject( m_property->getObject(), getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return OObject(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/OCompoundProperty.cpp000066400000000000000000000176031507001531700220760ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** OCompoundProperty::OCompoundProperty( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1 ) { init( iParent, iName, iArg0, iArg1 ); } //-***************************************************************************** OCompoundProperty::OCompoundProperty( OCompoundProperty iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1 ) { init( iParent.getPtr(), iName, iArg0, iArg1 ); } //-***************************************************************************** OCompoundProperty::OCompoundProperty( AbcA::CompoundPropertyWriterPtr iProp, const Argument &iArg0, const Argument &iArg1 ) : OBasePropertyT( iProp, GetErrorHandlerPolicy( iProp, iArg0, iArg1 ) ) { } //-***************************************************************************** OCompoundProperty::OCompoundProperty( AbcA::CompoundPropertyWriterPtr iProp, WrapExistingFlag iWrapFlag, const Argument &iArg0, const Argument &iArg1 ) : OBasePropertyT( iProp, GetErrorHandlerPolicy( iProp, iArg0, iArg1 ) ) { } //-***************************************************************************** OCompoundProperty::OCompoundProperty( OObject iObject, const Argument &iArg0, const Argument &iArg1 ) { init( iObject, iArg0, iArg1 ); } //-***************************************************************************** OCompoundProperty::OCompoundProperty( OObject iObject, TopFlag iTopFlag, const Argument &iArg0, const Argument &iArg1 ) { init( iObject, iArg0, iArg1 ); } //-***************************************************************************** OCompoundProperty::~OCompoundProperty() { // Here for debug support } //-***************************************************************************** size_t OCompoundProperty::getNumProperties() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCompoundProperty::getNumProperties()" ); return m_property->getNumProperties(); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return 0; } namespace { const AbcA::PropertyHeader g_hd; } //-***************************************************************************** const AbcA::PropertyHeader &OCompoundProperty::getPropertyHeader( size_t iIdx ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCompoundProperty::getPropertyHeader()" ); return m_property->getPropertyHeader( iIdx ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return g_hd; } //-***************************************************************************** const AbcA::PropertyHeader * OCompoundProperty::getPropertyHeader( const std::string &iName ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCompoundProperty::getPropertyHeader()" ); return m_property->getPropertyHeader( iName ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return NULL; } //-***************************************************************************** OBaseProperty OCompoundProperty::getProperty( size_t i ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCompoundProperty::getProperty( i )" ); return OBaseProperty( m_property->getProperty( i ), getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return OBaseProperty(); } //-***************************************************************************** OBaseProperty OCompoundProperty::getProperty( const std::string &iName ) const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCompoundProperty::getProperty( name )" ); return OBaseProperty( m_property->getProperty( iName ), getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return OBaseProperty(); } //-***************************************************************************** OCompoundProperty OCompoundProperty::getParent() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCompoundProperty::getParent()" ); return OCompoundProperty( m_property->getParent(), getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return OCompoundProperty(); } //-***************************************************************************** void OCompoundProperty::init( OObject iObject, const Argument &iArg0, const Argument &iArg1 ) { getErrorHandler().setPolicy( GetErrorHandlerPolicy( iObject, iArg0, iArg1 ) ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCompoundProperty::init( OObject )" ); m_property = iObject.getProperties().getPtr(); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } //-***************************************************************************** void OCompoundProperty::init( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCompoundProperty::init()" ); ABCA_ASSERT( iParent, "invalid parent" ); Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); m_property = Alembic::Util::dynamic_pointer_cast< AbcA::CompoundPropertyWriter>( iParent->getProperty( iName ) ); if ( !m_property ) { m_property = iParent->createCompoundProperty( iName, args.getMetaData() ); } ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/OCompoundProperty.h000066400000000000000000000161301507001531700215350ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_OCompoundProperty_h #define Alembic_Abc_OCompoundProperty_h #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** class ALEMBIC_EXPORT OCompoundProperty : public OBasePropertyT { public: //! By convention we always define this_type in Abc classes //! Used by unspecified-bool-type conversion below typedef OCompoundProperty this_type; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty OCompoundProperty function set. //! ... OCompoundProperty() : OBasePropertyT() {} //! Create a new OCompoundProperty named iName as a child of iParent. //! The remaining optional arguments can be used to override the //! ErrorHandlerPolicy, or to specify MetaData. OCompoundProperty( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ); //! Create a new OCompoundProperty named iName as a child of iParent. //! The remaining optional arguments can be used to override the //! ErrorHandlerPolicy, or to specify MetaData. OCompoundProperty( OCompoundProperty iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ); //! This attaches an OCompoundProperty wrapper around an existing //! CompoundPropertyWriterPtr, with an optional error handling policy. OCompoundProperty( AbcA::CompoundPropertyWriterPtr iProp, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ); // Deprecated in favor of the constructor above OCompoundProperty( AbcA::CompoundPropertyWriterPtr iProp, WrapExistingFlag iWrapFlag = kWrapExisting, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ); //! This attaches an OCompoundProperty wrapper around the top //! properties of an OObject. OCompoundProperty( OObject iObject, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ); // Deprecated in favor of the constructor above OCompoundProperty( OObject iObject, TopFlag iTopFlag = kTop, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ); //! Default copy constructor used //! Default assignment operator used. //! Destructor //! ... ~OCompoundProperty(); //-************************************************************************* // COMPOUND PROPERTY WRITER FUNCTIONALITY //-************************************************************************* //! Returns the number of properties that have been created thus far. //! May change as more are created. size_t getNumProperties() const; //! Return the header of a property that has already been added. //! Property is selected by index. //! This will throw an exception on out-of-range access. const AbcA::PropertyHeader & getPropertyHeader( size_t i ) const; //! Return the header of a property that has already been added. //! Property is selected by name. //! This will return NULL if no property with the given name is found. const AbcA::PropertyHeader * getPropertyHeader( const std::string &iName ) const; //! Return a wrapped base property version of an ALREADY ADDED property. //! Will return an empty pointer if the writer for this property //! no longer exists or was never added. //! This would primarily be used for introspection. OBaseProperty getProperty( size_t i ) const; //! Return a wrapped base property version of an ALREADY ADDED property. //! Will return an empty pointer if the writer for this property //! no longer exists or was never added. //! This would primarily be used for introspection. OBaseProperty getProperty( const std::string &iName ) const; //! Return the parent compound property, handily wrapped in a //! OCompoundProperty wrapper. OCompoundProperty getParent() const; private: void init( OObject iObject, const Argument &iArg0, const Argument &iArg1 ); void init( AbcA::CompoundPropertyWriterPtr iParentObject, const std::string &iName, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 = Argument() ); }; //-***************************************************************************** inline AbcA::CompoundPropertyWriterPtr GetCompoundPropertyWriterPtr ( OCompoundProperty iPrp ) { return iPrp.getPtr(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/OObject.cpp000066400000000000000000000224371507001531700177540ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** OObject::OObject( OObject iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 ) { init( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent ), iArg0, iArg1, iArg2 ); } //-***************************************************************************** OObject::~OObject() { // Nothing for now. // Mostly here in case we need to add reference-counting debug code. //std::cout << "OObject::~OObject() name: " // << m_object->getName() // << std::endl // << "\tUse count of writer ptr: " // << m_object.use_count() << std::endl; } namespace { const AbcA::ObjectHeader g_ohd; } //-***************************************************************************** const AbcA::ObjectHeader &OObject::getHeader() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::getHeader()" ); if ( m_object ) { return m_object->getHeader(); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, so have a default behavior. return g_ohd; }; //-***************************************************************************** OArchive OObject::getArchive() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::getArchive()" ); if ( m_object ) { return OArchive( m_object->getArchive(), getErrorHandlerPolicy() ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return OArchive(); } //-***************************************************************************** OObject OObject::getParent() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::getParent()" ); if ( m_object ) { return OObject( m_object->getParent(), getErrorHandlerPolicy() ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return OObject(); } //-***************************************************************************** size_t OObject::getNumChildren() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::getNumChildren()" ); if ( m_object ) { return m_object->getNumChildren(); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return 0; } //-***************************************************************************** const AbcA::ObjectHeader &OObject::getChildHeader( size_t iIdx ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::getChildHeader()" ); if ( m_object ) { return m_object->getChildHeader( iIdx ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return g_ohd; } //-***************************************************************************** const AbcA::ObjectHeader *OObject::getChildHeader( const std::string &iName ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::getChildHeader()" ); if ( m_object ) { return m_object->getChildHeader( iName ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return NULL; } //-***************************************************************************** OObject OObject::getChild( size_t iIdx ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::getChild( idx )" ); if ( m_object ) { AbcA::ObjectWriterPtr child = m_object->getChild( iIdx ); return OObject( child, getErrorHandlerPolicy() ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return OObject(); } //-***************************************************************************** OObject OObject::getChild( const std::string &iName ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::getChild( name )" ); if ( m_object ) { return OObject( m_object->getChild( iName ), getErrorHandlerPolicy() ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return OObject(); } //-***************************************************************************** OCompoundProperty OObject::getProperties() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::getProperties()" ); if ( m_object ) { return OCompoundProperty( m_object->getProperties(), kWrapExisting ); } ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return OCompoundProperty(); } //-***************************************************************************** bool OObject::addChildInstance( OObject iTarget, const std::string& iName ) { if ( !iTarget || !m_object ) return false; if ( iName.empty() ) return false; // Instance and source target must be in the same archive. if ( getArchive().getName() != iTarget.getArchive().getName() ) return false; // Cannot instance an instance, an instance created by normal means wouldn't // even be gettable, so this is a check for extraordinary circumstances. if ( iTarget.getMetaData().get("isInstance") == "1" ) return false; // Check that the instance target is not an ancestor of this object. std::string targetFullName = iTarget.getFullName(); std::string childFullName = getFullName() + "/" + iName; std::string targetPath = targetFullName + "/"; if ( childFullName.find(targetPath) == 0 ) return false; ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::addChildInstance()" ); AbcA::MetaData md; md.set("isInstance", "1"); OObject instanceChild = OObject( *this, iName, md ); OStringProperty instanceProp = OStringProperty( instanceChild.getProperties(), ".instanceSource" ); instanceProp.set( targetFullName ); return true; ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw, have a default. return false; } void OObject::init( OArchive & iArchive, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 ) { // Set the error handling policy getErrorHandler().setPolicy( GetErrorHandlerPolicy( iArchive.getPtr(), iArg0, iArg1, iArg2 ) ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::init( OArchive )" ); m_object = iArchive.getPtr()->getTop(); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } //-***************************************************************************** void OObject::init( AbcA::ObjectWriterPtr iParent, const std::string &iName, ErrorHandler::Policy iParentPolicy, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 ) { Arguments args( iParentPolicy ); iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "OObject::init()" ); AbcA::ObjectHeader ohdr( iName, args.getMetaData() ); m_object = iParent->createChild( ohdr ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/OObject.h000066400000000000000000000236251507001531700174210ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_OObject_h #define Alembic_Abc_OObject_h #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { class OCompoundProperty; //-***************************************************************************** class ALEMBIC_EXPORT OObject : public Base { public: //! By convention, we always define "this_type" in every Abc //! class. This convention is relied upon by the unspecified-bool-type //! conversion. typedef OObject this_type; typedef OObject operator_bool_base_type; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty OObject function set. //! ... OObject() {} //! This creates a new object writer. //! The first argument is the parent OObject from which the error handler //! policy for inheritance is derived. The remaining optional arguments //! can be used to override the ErrorHandlerPolicy, and MetaData OObject( OObject iParentObject, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument() ); //! This attaches an OObject wrapper around an existing //! ObjectWriterPtr, with an optional error handling policy. //! Arguments can be used to set error handling policy. OObject( AbcA::ObjectWriterPtr iPtr, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument() ) : m_object( iPtr ) { // Set the error handling policy getErrorHandler().setPolicy( GetErrorHandlerPolicy( iPtr, iArg0, iArg1, iArg2 ) ); } // Deprecated in favor of the constructor above OObject( AbcA::ObjectWriterPtr iPtr, WrapExistingFlag /* iFlag */, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument() ) : m_object( iPtr ) { // Set the error handling policy getErrorHandler().setPolicy( GetErrorHandlerPolicy( iPtr, iArg0, iArg1, iArg2 ) ); } //! This attaches an OObject wrapper around the top //! object in an archive. //! Arguments can be used to set error handling policy. OObject( OArchive & iArchive, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument() ) { init( iArchive, iArg0, iArg1, iArg2 ); } // deprecated in favor of the constructor above OObject( OArchive & iArchive, TopFlag /* iTop */, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument() ) { init( iArchive, iArg0, iArg1, iArg2 ); } //! Default copy constructor used //! Default assignment operator used. //! Destructor //! ... virtual ~OObject(); //-************************************************************************* // OBJECT WRITER FUNCTIONALITY //-************************************************************************* //! Return the object's header. //! ... const AbcA::ObjectHeader & getHeader() const; //! This function returns the object's local name //! ... const std::string &getName() const { return getHeader().getName(); } //! This function returns the object's full (unique with the archive) //! name const std::string &getFullName() const { return getHeader().getFullName(); } //! This function returns the object's metadata. //! ... const AbcA::MetaData &getMetaData() const { return getHeader().getMetaData(); } //! This function returns the object's archive, handily //! wrapped in an OArchive wrapper. OArchive getArchive(); //! This function returns the object's parent, handily //! wrapped in an OObject wrapper. If the object is the top //! level object, the OObject returned will be NULL. OObject getParent(); //! This function returns the number of child objects that //! this object has. This may change as new children //! are created for writing. size_t getNumChildren(); //! This function returns the headers of each of the child //! objects created so far. const AbcA::ObjectHeader & getChildHeader( size_t i ); //! This function returns the header of a named object if it has //! been created - even if the object no longer exists. const AbcA::ObjectHeader * getChildHeader( const std::string &iName ); //! This returns the single top-level OCompoundProperty that exists //! automatically as part of the object. OCompoundProperty getProperties(); //-************************************************************************* // ADVANCED TOOLS // Unless you really know why you need to be using these next few // functions, they're probably best left alone. These functions attempt // to find a pointer to an existing writer, instead of creating a new one. //-************************************************************************* //! This function returns an OObject wrapped around a pointer //! to an already created child. This is distinct from creating a new //! OObject as a child. If the writer associated with this child no longer //! exists, this function will return an empty OObject. OObject getChild( size_t iChildIndex ); //! This function returns an OObject wrapped around a pointer //! to an already created child. This is distinct from creating a new //! OObject as a child. If the writer associated with this child no longer //! exists, this function will return an empty OObject. OObject getChild( const std::string &iChildName ); //!-************************************************************************ // PROXY METHODS // An OObject can refer to another OObject. When read in, this instance // will be represented by the target source hierarchy and its children. //!-************************************************************************ bool addChildInstance( OObject iTarget, const std::string& iName ); //-************************************************************************* // ABC BASE MECHANISMS // These functions are used by Abc to deal with errors, rewrapping, // and so on. //-************************************************************************* //! getPtr, as usual, returns a shared ptr to the //! underlying AbcCoreAbstract object, in this case the //! ObjectWriterPtr. AbcA::ObjectWriterPtr getPtr() { return m_object; } const AbcA::ObjectWriterPtr getPtr() const { return m_object; } //! Reset returns this function set to an empty, default //! state. void reset() { m_object.reset(); Base::reset(); } //! Valid returns whether this function set is //! valid. bool valid() const { return ( Base::valid() && m_object ); } //! The unspecified-bool-type operator casts the object to "true" //! if it is valid, and "false" otherwise. ALEMBIC_OPERATOR_BOOL( valid() ); private: void init( OArchive & iArchive, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 ); void init( AbcA::ObjectWriterPtr iParentObject, const std::string &iName, ErrorHandler::Policy iParentPolicy, const Argument &iArg0, const Argument &iArg1, const Argument &iARg2 ); protected: AbcA::ObjectWriterPtr m_object; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/OScalarProperty.cpp000066400000000000000000000151021507001531700215070ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** OScalarProperty::OScalarProperty( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const AbcA::DataType &iDataType, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2, const Argument &iArg3 ) { init( iParent, iName, iDataType, iArg0, iArg1, iArg2, iArg3 ); } //-***************************************************************************** OScalarProperty::OScalarProperty( OCompoundProperty iParent, const std::string &iName, const AbcA::DataType &iDataType, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 ) { init( iParent.getPtr(), iName, iDataType, GetErrorHandlerPolicy( iParent ), iArg0, iArg1, iArg2 ); } //-***************************************************************************** OScalarProperty::~OScalarProperty() { // Nothing for now. // Mostly here in case we need to add reference-counting debug code. } //-***************************************************************************** size_t OScalarProperty::getNumSamples() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OScalarProperty::getNumSamples()" ); return m_property->getNumSamples(); ALEMBIC_ABC_SAFE_CALL_END(); return 0; } //-***************************************************************************** void OScalarProperty::set( const void *iSamp ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OScalarProperty::set()" ); m_property->setSample( iSamp ); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** void OScalarProperty::setFromPrevious() { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OScalarProperty::setFromPrevious()" ); m_property->setFromPreviousSample(); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** void OScalarProperty::setTimeSampling( uint32_t iIndex ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OScalarProperty::setTimeSampling(uint32_t)" ); m_property->setTimeSamplingIndex(iIndex); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** void OScalarProperty::setTimeSampling( AbcA::TimeSamplingPtr iTime ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OScalarProperty::setTimeSampling()" ); uint32_t tsIndex = m_property->getParent()->getObject()->getArchive()->addTimeSampling( *iTime); m_property->setTimeSamplingIndex(tsIndex); ALEMBIC_ABC_SAFE_CALL_END(); } //-***************************************************************************** OCompoundProperty OScalarProperty::getParent() const { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OScalarProperty::getParent()" ); return OCompoundProperty( m_property->getParent(), getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_END(); // Not all error handlers throw. Have a default. return OCompoundProperty(); } //-***************************************************************************** void OScalarProperty::init( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const AbcA::DataType &iDataType, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2, const Argument &iArg3 ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); iArg3.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "OScalarProperty::init(p, n)" ); AbcA::TimeSamplingPtr tsPtr = args.getTimeSampling(); uint32_t tsIndex = args.getTimeSamplingIndex(); // if we specified a valid TimeSamplingPtr, use it to determine the index // otherwise we'll use the index, which defaults to the intrinsic 0 index if (tsPtr) { tsIndex = iParent->getObject()->getArchive()->addTimeSampling(*tsPtr); } m_property = iParent->createScalarProperty( iName, args.getMetaData(), iDataType, tsIndex ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace Abc } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/OScalarProperty.h000066400000000000000000000156021507001531700211610ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_OScalarProperty_h #define Alembic_Abc_OScalarProperty_h #include #include #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** class ALEMBIC_EXPORT OScalarProperty : public OBasePropertyT { public: //! By convention we always define this_type in Abc classes //! Used by unspecified-bool-type conversion below typedef OScalarProperty this_type; //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty OScalarProperty function set. //! ... OScalarProperty() : OBasePropertyT() {} //! Create a new OScalarProperty named iName as a child of compound iParent, //! of data type iDataType. The remaining optional arguments can be used //! the inherited parent ErrorHandlerPolicy, an override to that policy, //! specify MetaData, and to specify time sampling or time sampling index. OScalarProperty( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const AbcA::DataType &iDataType, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument(), const Argument &iArg3 = Argument() ); //! Create a new OScalarProperty named iName as a child of compound iParent, //! of data type iDataType. The remaining optional arguments can be used //! to override the ErrorHandlerPolicy, specify MetaData, //! and to specify time sampling or time sampling index. OScalarProperty( OCompoundProperty iParent, const std::string &iName, const AbcA::DataType &iDataType, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument() ); //! This attaches an OScalarProperty wrapper around an existing //! ScalarPropertyWriterPtr, arguments are there to specify //! ErrorHandling policy, OScalarProperty( AbcA::ScalarPropertyWriterPtr iPtr, ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy ) : OBasePropertyT( iPtr, iPolicy ) {} // Deprecated in favor of the constructor above OScalarProperty( AbcA::ScalarPropertyWriterPtr iPtr, WrapExistingFlag iWrapFlag, ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy ) : OBasePropertyT( iPtr, iPolicy ) {} //! Default copy constructor used //! Default assignment operator used. //! Destructor //! ... ~OScalarProperty(); //-************************************************************************* // SCALAR PROPERTY WRITER FUNCTIONALITY //-************************************************************************* //! Return the number of samples contained in the property. //! This can be any number, including zero. //! This returns the number of samples that were written, independently //! of whether or not they were constant. //! It make change over time as more samples are written. size_t getNumSamples() const; //! Set a sample from the address of a datum. //! ... void set( const void *iSample ); //! Set a sample from the previous sample. //! ... void setFromPrevious( ); //! Changes the TimeSampling used by this property. //! If the TimeSampling is changed to Acyclic and the number of samples //! currently set is more than the number of times provided in the Acyclic //! TimeSampling, an exception will be thrown. void setTimeSampling( uint32_t iIndex ); //! Changes the TimeSampling used by this property. //! If the TimeSampling is changed to Acyclic and the number of samples //! currently set is more than the number of times provided in the Acyclic //! TimeSampling, an exception will be thrown. void setTimeSampling( AbcA::TimeSamplingPtr iTime ); //! Return the parent compound property, handily wrapped in a //! OCompoundProperty wrapper. OCompoundProperty getParent() const; private: void init( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const AbcA::DataType &iDataType, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2, const Argument &iArg3 ); }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/OSchema.h000066400000000000000000000264631507001531700174160ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_OSchema_h #define Alembic_Abc_OSchema_h #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! With properties, specific flavors of properties are expressed via the //! TypedScalarProperty and the TypedArrayProperty. Compound Properties //! are more complex, and the specific flavors require a more complex //! treatment - That's what Schemas are. The CompoundProperty equivalent //! of a TypedArrayProperty or a TypedScalarProperty. //! //! A Schema is a collection of grouped properties which implement some //! complex object, such as a poly mesh. In the simpelest, standard case, //! there will be a compound property at the top with a certain name, and //! inside the compound property will be some number of additional properties //! that implement the object. In the case of a poly mesh, these properties //! would include a list of vertices (a V3fArray), a list of indices //! (an Int32Array), and a list of "per-face counts" (also an Int32Array). //! //! In somewhat more complex cases, such as a TransformStack, the set of //! properties that are added may vary based on configuration information //! provided by the user. //! //! Because a Schema is to a CompoundProperty what a TypedArrayProperty //! or TypedScalarProperty is to a regular property, it is directly derived //! from CompoundProperty. However... Whereas TypedProperties can be instanced //! as typedefs, Schemas will invariably require additional functionality, //! and thus the StdCompoundSchema is intended for use as a base class. //! //-***************************************************************************** //-***************************************************************************** //! With properties, specific flavors of properties are expressed via the //! TypedScalarProperty and the TypedArrayProperty. Compound Properties //! are more complex, and the specific flavors require a more complex //! treatment - That's what Schemas are. The CompoundProperty equivalent //! of a TypedArrayProperty or a TypedScalarProperty. //! //! A Schema is a collection of grouped properties which implement some //! complex object, such as a poly mesh. In the simpelest, standard case, //! there will be a compound property at the top with a certain name, and //! inside the compound property will be some number of additional properties //! that implement the object. In the case of a poly mesh, these properties //! would include a list of vertices (a V3fArray), a list of indices //! (an Int32Array), and a list of "per-face counts" (also an Int32Array). //-***************************************************************************** //! Here is a macro for declaring SCHEMA_INFO //! It takes these arguments //! - the SchemaTitle( a string ), //! - the SchemaBaseType( a string ), //! - the DefaultSchemaName( a string ), //! - whether to set replace when the sparse argument is provided( bool ), //! - the name of the SchemaInfo Type to be declared. //! - for example: //! ALEMBIC_ABC_DECLARE_SCHEMA_INFO( "AbcGeom_PolyMesh_v1", //! "AbcGeom_GeomBase_v1", //! ".geom", //! false, //! PolyMeshSchemaInfo ); #define ALEMBIC_ABC_DECLARE_SCHEMA_INFO( STITLE, SBTYP, SDFLT, SPREP, STDEF ) \ struct STDEF \ { \ static const char * title() { return ( STITLE ) ; } \ static const char * defaultName() { return ( SDFLT ); } \ static const char * schemaBaseType() { return ( SBTYP ); } \ static bool replaceOnSparse() { return SPREP; } \ } //-***************************************************************************** //! Usually used as a base class, but could also theoretically be used //! as a standalone template class OSchema : public OCompoundProperty { public: //-************************************************************************* // TYPEDEFS AND IDENTIFIERS //-************************************************************************* typedef INFO info_type; typedef OSchema this_type; //! Return the schema title expected of this //! property. An empty title matches everything static const char * getSchemaTitle() { return INFO::title(); } //! Return the schema base type expected of this //! property. An empty base type means it's the root type. static const char * getSchemaBaseType() { return INFO::schemaBaseType(); } //! Return the default name for instances of this schema. Often //! something like ".geom" static const char * getDefaultSchemaName() { return INFO::defaultName(); } //! Returns whether this schema also sets replace in the MetaData if //! kSparse is passed into the args. For some schemas like xforms it //! doesn't make sense to sparsely override the properties, instead //! you want to replace everything on the schema with a whole set of new //! properties, or even NO properties. static bool replaceOnSparse() { return INFO::replaceOnSparse(); } //! This will check whether or not a given entity (as represented by //! a metadata) strictly matches the interpretation of this //! schema object static bool matches( const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching = kStrictMatching ) { if ( std::string() == getSchemaTitle() || iMatching == kNoMatching ) { return true; } if ( iMatching == kStrictMatching || iMatching == kSchemaTitleMatching ) { return iMetaData.get( "schema" ) == getSchemaTitle(); } return false; } //! This will check whether or not a given object (as represented by //! an object header) strictly matches the interpretation of this //! schema object, as well as the data type. static bool matches( const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching = kStrictMatching ) { return matches( iHeader.getMetaData(), iMatching ); } //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty OSchema //! function set. OSchema() {} //! Creates a new Compound Property Writer with the schema //! information added to the metadata. OSchema( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument(), const Argument &iArg3 = Argument() ) { this_type::init( iParent, iName, iArg0, iArg1, iArg2, iArg3 ); } //! Creates a new Compound Property Writer with the schema //! information added to the metadata. OSchema( OCompoundProperty iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument() ) { *this = OSchema( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent ), iArg0, iArg1, iArg2); } virtual ~OSchema() {} //! Default copy constructor used //! Default assignment operator used. private: void init( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2, const Argument &iArg3 ); }; //-***************************************************************************** // TEMPLATE AND INLINE FUNCTIONS //-***************************************************************************** template void OSchema::init( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2, const Argument &iArg3 ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); iArg3.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "OSchema::OSchema::init()" ); // Get actual writer for parent. ABCA_ASSERT( iParent, "NULL parent passed into OSchema ctor" ); // Put schema title into metadata. AbcA::MetaData mdata = args.getMetaData(); std::string emptyStr; if ( emptyStr != getSchemaTitle() && !args.isSparse() ) { mdata.set( "schema", getSchemaTitle() ); } if ( emptyStr != getSchemaBaseType() && !args.isSparse() ) { mdata.set( "schemaBaseType", getSchemaBaseType() ); } // Create property. m_property = iParent->createCompoundProperty( iName, mdata ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/OSchemaObject.h000066400000000000000000000211521507001531700205330ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_OSchemaObject_h #define Alembic_Abc_OSchemaObject_h #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! An OSchemaObject is an object with a single schema. This is just //! a convenience class, really, but it also deals with setting up and //! validating metadata template class OSchemaObject : public OObject { public: //-************************************************************************* // TYPEDEFS AND IDENTIFIERS //-************************************************************************* typedef SCHEMA schema_type; typedef OSchemaObject this_type; //! Our schema title contains the schema title of the underlying //! compound property, along with the default name of that compound //! property. So, for example - most AbcGeom types put their //! data in ".geom", so, "AbcGeom_PolyMesh_v1:.geom" //! Sometimes schema titles from underlying schemas are "", but //! ours never are. static std::string getSchemaObjTitle() { return SCHEMA::getSchemaTitle() + std::string( ":" ) + SCHEMA::getDefaultSchemaName(); } static const char * getSchemaTitle() { return SCHEMA::getSchemaTitle(); } //! This will check whether or not a given entity (as represented by //! a metadata) strictly matches the interpretation of this //! schema object static bool matches( const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching = kStrictMatching ) { if ( std::string() == getSchemaTitle() || iMatching == kNoMatching ) { return true; } if ( iMatching == kStrictMatching ) { return iMetaData.get( "schemaObjTitle" ) == getSchemaObjTitle(); } if ( iMatching == kSchemaTitleMatching ) { return iMetaData.get( "schema" ) == getSchemaTitle(); } return false; } //! This will check whether or not a given object (as represented by //! an object header) strictly matches the interpretation of this //! schema object, as well as the data type. static bool matches( const AbcA::ObjectHeader &iHeader, SchemaInterpMatching iMatching = kStrictMatching ) { return matches( iHeader.getMetaData(), iMatching ); } //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! The default constructor creates an empty OSchemaObject function set. //! ... OSchemaObject() {} //! The primary constructor creates an OSchemaObject as a child of the //! first argument, which is any Abc or AbcCoreAbstract (or other) //! object which can be intrusively cast to an ObjectWriterPtr. OSchemaObject( OObject iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument() ); //-************************************************************************* // ABC BASE MECHANISMS // These functions are used by Abc to deal with errors, validity, // and so on. //-************************************************************************* //! Schemas are not necessarily cheap to copy, so we return by reference //! rather than by value. SCHEMA &getSchema() { return m_schema; } const SCHEMA &getSchema() const { return m_schema; } //! Reset returns this function set to an empty, default //! state. void reset() { m_schema.reset(); OObject::reset(); } //! Valid returns whether this function set is //! valid. bool valid() const { return ( OObject::valid() && m_schema.valid() ); } //! The unspecified-bool-type operator casts the object to "true" //! if it is valid, and "false" otherwise. ALEMBIC_OVERRIDE_OPERATOR_BOOL( this_type::valid() ); protected: SCHEMA m_schema; }; //-***************************************************************************** // TEMPLATE AND INLINE FUNCTIONS //-***************************************************************************** //-***************************************************************************** template OSchemaObject::OSchemaObject ( OObject iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2 ) { Arguments args( GetErrorHandlerPolicy( iParent ) ); iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "OSchemaObject::OSchemaObject( OObject )" ); // Extract the parent. AbcA::ObjectWriterPtr parent = iParent.getPtr(); ABCA_ASSERT( parent, "NULL Parent ObjectWriter in OSchemaObject ctor" ); // The object schema title is derived from the schema's title. // It is never empty (unless sparse) AbcA::MetaData metaData = args.getMetaData(); SparseFlag sparseFlag = kSparse; if ( !args.isSparse() ) { sparseFlag = kFull; metaData.set( "schema", SCHEMA::getSchemaTitle() ); metaData.set( "schemaObjTitle", getSchemaObjTitle() ); if ( std::string() != SCHEMA::getSchemaBaseType() ) { metaData.set( "schemaBaseType", SCHEMA::getSchemaBaseType() ); } } // Make the object. AbcA::ObjectHeader ohdr( iName, metaData ); m_object = parent->createChild( ohdr ); AbcA::TimeSamplingPtr tsPtr = args.getTimeSampling(); uint32_t tsIndex = args.getTimeSamplingIndex(); // if we specified a valid TimeSamplingPtr, use it to determine the index // otherwise we'll use the index, which defaults to the intrinsic 0 index if (tsPtr) { tsIndex = parent->getArchive()->addTimeSampling(*tsPtr); } AbcA::MetaData schemaMetaData; if ( args.isSparse() && SCHEMA::replaceOnSparse() ) { schemaMetaData.set( "replace", "1" ); } // Make the schema. m_schema = SCHEMA( m_object->getProperties(), SCHEMA::getDefaultSchemaName(), this->getErrorHandlerPolicy(), tsIndex, schemaMetaData, sparseFlag ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/OTypedArrayProperty.h000066400000000000000000000317261507001531700220450ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_OTypedArrayProperty_h #define Alembic_Abc_OTypedArrayProperty_h #include #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** template class OTypedArrayProperty : public OArrayProperty { public: //-************************************************************************* // TYPEDEFS AND IDENTIFIERS //-************************************************************************* typedef TRAITS traits_type; typedef OTypedArrayProperty this_type; typedef typename TRAITS::value_type value_type; typedef TypedArraySample sample_type; //! Return the interpretation expected of this //! property. An empty interpretation matches everything static const char * getInterpretation() { return TRAITS::interpretation(); } //! This will check whether or not a given entity (as represented by //! a metadata) strictly matches the interpretation of this //! typed property static bool matches( const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching = kStrictMatching ) { return ( iMetaData.get( "interpretation" ) == getInterpretation() ); } //! This will check whether or not a given object (as represented by //! an property header) strictly matches the interpretation of this //! typed property, as well as the data type. static bool matches( const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching = kStrictMatching ) { return ( iHeader.getDataType().getPod() == TRAITS::dataType().getPod() && ( iHeader.getDataType().getExtent() == TRAITS::dataType().getExtent() || std::string() == getInterpretation() ) ) && iHeader.isArray() && matches( iHeader.getMetaData(), iMatching ); } //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! Create a default (empty) TypedArrayProperty //! ... OTypedArrayProperty() {} //! Create a new TypedArrayProperty //! as a child of the passed iParent //! Arguments can specify metadata, timesampling, and error handling. OTypedArrayProperty( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument(), const Argument &iArg3 = Argument() ) { init( iParent, iName, iArg0, iArg1, iArg2, iArg3 ); } //! Create a new TypedArrayProperty //! as a child of the passed iParent //! Arguments can specify metadata, timesampling, and error handling. OTypedArrayProperty( OCompoundProperty iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument() ) { init( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent ), iArg0, iArg1, iArg2 ); } //! Wrap an existing property. This will check to make sure //! it can wrap. OTypedArrayProperty( AbcA::ArrayPropertyWriterPtr iProp, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) : OArrayProperty( iProp, GetErrorHandlerPolicy( iProp, iArg0, iArg1 ) ) { init( iProp, iArg0, iArg1 ); } // Deprecated in favor of constructor above OTypedArrayProperty( AbcA::ArrayPropertyWriterPtr iProp, WrapExistingFlag iWrapFlag, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) : OArrayProperty( iProp, GetErrorHandlerPolicy( iProp, iArg0, iArg1 ) ) { init( iProp, iArg0, iArg1 ); } //-************************************************************************* // ARRAY PROPERTY FEATURES //-************************************************************************* //! Set a sample using a reference to a typed array sample-type, //! instead of a void* ArraySample void set( const sample_type &iVal ) { OArrayProperty::set( iVal ); } private: void init( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2, const Argument &iArg3 ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); iArg3.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "OTypedArrayProperty::init()" ); // Get actual writer for parent. ABCA_ASSERT( iParent, "NULL CompoundPropertyWriterPtr" ); // Put interpretation into metadata. AbcA::MetaData mdata = args.getMetaData(); if ( std::string() != getInterpretation() ) { mdata.set( "interpretation", getInterpretation() ); } // Create property. AbcA::TimeSamplingPtr tsPtr = args.getTimeSampling(); uint32_t tsIndex = args.getTimeSamplingIndex(); // if we specified a valid TimeSamplingPtr, use it to determine the // index otherwise we'll use the index, which defaults to the intrinsic // 0 index if (tsPtr) { tsIndex = iParent->getObject()->getArchive()->addTimeSampling( *tsPtr); } m_property = iParent->createArrayProperty( iName, mdata, TRAITS::dataType(), tsIndex ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } void init( AbcA::ArrayPropertyWriterPtr iProp, const Argument &iArg0, const Argument &iArg1 ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OTypedArrayProperty::init( ArrayPtr )" ); const AbcA::PropertyHeader &pheader = iProp->getHeader(); ABCA_ASSERT( matches( pheader, GetSchemaInterpMatching( iArg0,iArg1 ) ), "Incorrect match of header datatype: " << pheader.getDataType() << " to expected: " << TRAITS::dataType() << ",\n...or incorrect match of interpretation: " << pheader.getMetaData().get( "interpretation" ) << " to expected: " << TRAITS::interpretation() ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } }; //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** typedef OTypedArrayProperty OBoolArrayProperty; typedef OTypedArrayProperty OUcharArrayProperty; typedef OTypedArrayProperty OCharArrayProperty; typedef OTypedArrayProperty OUInt16ArrayProperty; typedef OTypedArrayProperty OInt16ArrayProperty; typedef OTypedArrayProperty OUInt32ArrayProperty; typedef OTypedArrayProperty OInt32ArrayProperty; typedef OTypedArrayProperty OUInt64ArrayProperty; typedef OTypedArrayProperty OInt64ArrayProperty; typedef OTypedArrayProperty OHalfArrayProperty; typedef OTypedArrayProperty OFloatArrayProperty; typedef OTypedArrayProperty ODoubleArrayProperty; typedef OTypedArrayProperty OStringArrayProperty; typedef OTypedArrayProperty OWstringArrayProperty; typedef OTypedArrayProperty OV2sArrayProperty; typedef OTypedArrayProperty OV2iArrayProperty; typedef OTypedArrayProperty OV2fArrayProperty; typedef OTypedArrayProperty OV2dArrayProperty; typedef OTypedArrayProperty OV3sArrayProperty; typedef OTypedArrayProperty OV3iArrayProperty; typedef OTypedArrayProperty OV3fArrayProperty; typedef OTypedArrayProperty OV3dArrayProperty; typedef OTypedArrayProperty OP2sArrayProperty; typedef OTypedArrayProperty OP2iArrayProperty; typedef OTypedArrayProperty OP2fArrayProperty; typedef OTypedArrayProperty OP2dArrayProperty; typedef OTypedArrayProperty OP3sArrayProperty; typedef OTypedArrayProperty OP3iArrayProperty; typedef OTypedArrayProperty OP3fArrayProperty; typedef OTypedArrayProperty OP3dArrayProperty; typedef OTypedArrayProperty OBox2sArrayProperty; typedef OTypedArrayProperty OBox2iArrayProperty; typedef OTypedArrayProperty OBox2fArrayProperty; typedef OTypedArrayProperty OBox2dArrayProperty; typedef OTypedArrayProperty OBox3sArrayProperty; typedef OTypedArrayProperty OBox3iArrayProperty; typedef OTypedArrayProperty OBox3fArrayProperty; typedef OTypedArrayProperty OBox3dArrayProperty; typedef OTypedArrayProperty OM33fArrayProperty; typedef OTypedArrayProperty OM33dArrayProperty; typedef OTypedArrayProperty OM44fArrayProperty; typedef OTypedArrayProperty OM44dArrayProperty; typedef OTypedArrayProperty OQuatfArrayProperty; typedef OTypedArrayProperty OQuatdArrayProperty; typedef OTypedArrayProperty OC3hArrayProperty; typedef OTypedArrayProperty OC3fArrayProperty; typedef OTypedArrayProperty OC3cArrayProperty; typedef OTypedArrayProperty OC4hArrayProperty; typedef OTypedArrayProperty OC4fArrayProperty; typedef OTypedArrayProperty OC4cArrayProperty; typedef OTypedArrayProperty ON2fArrayProperty; typedef OTypedArrayProperty ON2dArrayProperty; typedef OTypedArrayProperty ON3fArrayProperty; typedef OTypedArrayProperty ON3dArrayProperty; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/OTypedScalarProperty.h000066400000000000000000000306061507001531700221700ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_OTypedScalarProperty_h #define Alembic_Abc_OTypedScalarProperty_h #include #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** template class OTypedScalarProperty : public OScalarProperty { public: //-************************************************************************* // TYPE IDENTIFICATION //-************************************************************************* typedef TRAITS traits_type; typedef OTypedScalarProperty this_type; typedef typename TRAITS::value_type value_type; //! Return the interpretation expected of this //! property. An empty interpretation matches everything static const char * getInterpretation() { return TRAITS::interpretation(); } //! This will check whether or not a given entity (as represented by //! a metadata) strictly matches the interpretation of this //! schema object static bool matches( const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching = kStrictMatching ) { return ( iMetaData.get( "interpretation" ) == getInterpretation() ); } //! This will check whether or not a given object (as represented by //! an object header) strictly matches the interpretation of this //! schema object, as well as the data type. static bool matches( const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching = kStrictMatching ) { return ( iHeader.getDataType().getPod() == TRAITS::dataType().getPod() && ( iHeader.getDataType().getExtent() == TRAITS::dataType().getExtent() || std::string() == getInterpretation() ) ) && iHeader.isScalar() && matches( iHeader.getMetaData(), iMatching ); } //-************************************************************************* // CONSTRUCTION, DESTRUCTION, ASSIGNMENT //-************************************************************************* //! Create a default (empty) TypedScalarProperty //! ... OTypedScalarProperty() {} //! Create a new TypedScalarProperty //! as a child of the passed iParent //! Arguments can specify metadata, timesampling, and error handling. OTypedScalarProperty( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument(), const Argument &iArg3 = Argument() ) { init( iParent, iName, iArg0, iArg1, iArg2, iArg3 ); } //! Create a new TypedScalarProperty //! as a child of the passed iParent //! Arguments can specify metadata, timesampling, and error handling. OTypedScalarProperty( OCompoundProperty iParent, const std::string &iName, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument(), const Argument &iArg2 = Argument() ) { init( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent ), iArg0, iArg1, iArg2 ); } //! Wrap an existing scalar property, //! checking to make sure it matches data type and also //! (if requested) interpretation. OTypedScalarProperty( AbcA::ScalarPropertyWriterPtr iProp, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) : OScalarProperty( iProp, GetErrorHandlerPolicy( iProp, iArg0, iArg1 ) ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OTypedScalarProperty::OTypedScalarProperty()" ); const AbcA::PropertyHeader &pheader = iProp->getHeader(); ABCA_ASSERT( matches( pheader, GetSchemaInterpMatching( iArg0,iArg1 ) ), "Incorrect match of header datatype: " << pheader.getDataType() << " to expected: " << TRAITS::dataType() << ",\n...or incorrect match of interpretation: " << pheader.getMetaData().get( "interpretation" ) << " to expected: " << TRAITS::interpretation() ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } // Deprecated in favor of the constructor above OTypedScalarProperty( AbcA::ScalarPropertyWriterPtr iProp, WrapExistingFlag iWrapFlag, const Argument &iArg0 = Argument(), const Argument &iArg1 = Argument() ) { *this = OTypedScalarProperty( iProp, iArg0, iArg1 ); } //-************************************************************************* // SCALAR PROPERTY FEATURES //-************************************************************************* //! Set a sample using a reference to a value-type, //! instead of a void* void set( const value_type &iVal ) { OScalarProperty::set( reinterpret_cast( &iVal ) ); } private: void init( AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0, const Argument &iArg1, const Argument &iArg2, const Argument &iArg3 ) { Arguments args; iArg0.setInto( args ); iArg1.setInto( args ); iArg2.setInto( args ); iArg3.setInto( args ); getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); ALEMBIC_ABC_SAFE_CALL_BEGIN( "OTypedScalarProperty::init()" ); ABCA_ASSERT( iParent, "NULL CompoundPropertyWriterPtr" ); AbcA::MetaData mdata = args.getMetaData(); if ( std::string() != getInterpretation() ) { mdata.set( "interpretation", getInterpretation() ); } AbcA::TimeSamplingPtr tsPtr = args.getTimeSampling(); uint32_t tsIndex = args.getTimeSamplingIndex(); // if we specified a valid TimeSamplingPtr, use it to determine the // index otherwise we'll use the index, which defaults to the intrinsic // 0 index if (tsPtr) { tsIndex = iParent->getObject()->getArchive()->addTimeSampling( *tsPtr); } m_property = iParent->createScalarProperty( iName, mdata, TRAITS::dataType(), tsIndex ); ALEMBIC_ABC_SAFE_CALL_END_RESET(); } }; //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** typedef OTypedScalarProperty OBoolProperty; typedef OTypedScalarProperty OUcharProperty; typedef OTypedScalarProperty OCharProperty; typedef OTypedScalarProperty OUInt16Property; typedef OTypedScalarProperty OInt16Property; typedef OTypedScalarProperty OUInt32Property; typedef OTypedScalarProperty OInt32Property; typedef OTypedScalarProperty OUInt64Property; typedef OTypedScalarProperty OInt64Property; typedef OTypedScalarProperty OHalfProperty; typedef OTypedScalarProperty OFloatProperty; typedef OTypedScalarProperty ODoubleProperty; typedef OTypedScalarProperty OStringProperty; typedef OTypedScalarProperty OWstringProperty; typedef OTypedScalarProperty OV2sProperty; typedef OTypedScalarProperty OV2iProperty; typedef OTypedScalarProperty OV2fProperty; typedef OTypedScalarProperty OV2dProperty; typedef OTypedScalarProperty OV3sProperty; typedef OTypedScalarProperty OV3iProperty; typedef OTypedScalarProperty OV3fProperty; typedef OTypedScalarProperty OV3dProperty; typedef OTypedScalarProperty OP2sProperty; typedef OTypedScalarProperty OP2iProperty; typedef OTypedScalarProperty OP2fProperty; typedef OTypedScalarProperty OP2dProperty; typedef OTypedScalarProperty OP3sProperty; typedef OTypedScalarProperty OP3iProperty; typedef OTypedScalarProperty OP3fProperty; typedef OTypedScalarProperty OP3dProperty; typedef OTypedScalarProperty OBox2sProperty; typedef OTypedScalarProperty OBox2iProperty; typedef OTypedScalarProperty OBox2fProperty; typedef OTypedScalarProperty OBox2dProperty; typedef OTypedScalarProperty OBox3sProperty; typedef OTypedScalarProperty OBox3iProperty; typedef OTypedScalarProperty OBox3fProperty; typedef OTypedScalarProperty OBox3dProperty; typedef OTypedScalarProperty OM33fProperty; typedef OTypedScalarProperty OM33dProperty; typedef OTypedScalarProperty OM44fProperty; typedef OTypedScalarProperty OM44dProperty; typedef OTypedScalarProperty OQuatfProperty; typedef OTypedScalarProperty OQuatdProperty; typedef OTypedScalarProperty OC3hProperty; typedef OTypedScalarProperty OC3fProperty; typedef OTypedScalarProperty OC3cProperty; typedef OTypedScalarProperty OC4hProperty; typedef OTypedScalarProperty OC4fProperty; typedef OTypedScalarProperty OC4cProperty; typedef OTypedScalarProperty ON2fProperty; typedef OTypedScalarProperty ON2dProperty; typedef OTypedScalarProperty ON3fProperty; typedef OTypedScalarProperty ON3dProperty; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/Reference.cpp000066400000000000000000000044021507001531700203150ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { void SetReference( AbcA::MetaData &ioMetaData ) { ioMetaData.set( "reference", "1" ); } bool isReference( const AbcA::PropertyHeader &iHeader ) { return ( iHeader.getMetaData().get( "reference" ) == "1" ); } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcGeom } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/Reference.h000066400000000000000000000044751507001531700177740ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_Reference_h #define Alembic_Abc_Reference_h #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { ALEMBIC_EXPORT void SetReference( AbcA::MetaData &ioMetaData ); ALEMBIC_EXPORT bool isReference( const AbcA::PropertyHeader &iHeader ); } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/SourceName.cpp000066400000000000000000000044211507001531700204610ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { void SetSourceName( AbcA::MetaData &ioMetaData, const std::string & iName ) { ioMetaData.set( "sourceName", iName ); } std::string GetSourceName( const AbcA::MetaData &iMetaData ) { return iMetaData.get( "sourceName" ); } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcGeom } // End namespace Alembic alembic-1.8.9/lib/Alembic/Abc/SourceName.h000066400000000000000000000045401507001531700201300ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_SourceName_h #define Alembic_Abc_SourceName_h #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { ALEMBIC_EXPORT void SetSourceName( AbcA::MetaData &ioMetaData, const std::string & iName ); ALEMBIC_EXPORT std::string GetSourceName( const AbcA::MetaData &iMetaData ); } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/Tests/000077500000000000000000000000001507001531700170155ustar00rootroot00000000000000alembic-1.8.9/lib/Alembic/Abc/Tests/ArchiveTest.cpp000066400000000000000000000223561507001531700217520ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2015, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif namespace Abc = Alembic::Abc; namespace AbcF = Alembic::AbcCoreFactory; using namespace Abc; void archiveInfoTest(bool useOgawa) { std::string appWriter = "Alembic unit tests"; std::string userStr = "abcdefg"; { Alembic::AbcCoreAbstract::MetaData md; md.set("potato", "salad"); md.set("taco", "bar"); OArchive archive, archive2; if (useOgawa) { archive = CreateArchiveWithInfo( Alembic::AbcCoreOgawa::WriteArchive(), "archiveInfo.abc", appWriter, userStr, md ); archive2 = CreateArchiveWithInfo( Alembic::AbcCoreOgawa::WriteArchive(), "archiveInfoWFPS.abc", 42, appWriter, userStr, md ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = CreateArchiveWithInfo( Alembic::AbcCoreHDF5::WriteArchive(), "archiveInfo.abc", appWriter, userStr, md ); archive2 = CreateArchiveWithInfo( Alembic::AbcCoreHDF5::WriteArchive(), "archiveInfoWFPS.abc", 42, appWriter, userStr, md ); } #endif TESTING_ASSERT( archive.getPtr()->getMetaData().get("taco") == "bar" ); TESTING_ASSERT( archive2.getPtr()->getMetaData().get("taco") == "bar" ); //TESTING_ASSERT( archive2.getPtr()->getMetaData().get( kDCCFPSKey ) // == "42" ); } { AbcF::IFactory factory; AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive("archiveInfo.abc", coreType); TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) || (!useOgawa && coreType == AbcF::IFactory::kHDF5) ); TESTING_ASSERT( archive.getPtr()->getMetaData().get("taco") == "bar" ); TESTING_ASSERT( archive.getPtr()->getMetaData().get("potato") == "salad" ); TESTING_ASSERT( archive.getArchiveVersion() == ALEMBIC_LIBRARY_VERSION ); std::string appInfo; std::string abcVersionStr; Alembic::Util::uint32_t abcVersion = 0; std::string dateWritten; std::string userInfo; GetArchiveInfo( archive, appInfo, abcVersionStr, abcVersion, dateWritten, userInfo ); TESTING_ASSERT( appWriter == appInfo ); TESTING_ASSERT( userStr == userInfo ); TESTING_ASSERT( abcVersion == ALEMBIC_LIBRARY_VERSION ); std::cout << "Alembic version: " << abcVersionStr << std::endl; std::cout << "Date written: " << dateWritten << std::endl; TESTING_ASSERT( dateWritten != "" ); TESTING_ASSERT( abcVersionStr != "" ); // test it again but the DCC FPS variant, pass in a bogus value // to show that it gets reset to 0 when it doesn't exist double dcc_fps = 123; GetArchiveInfo( archive, appInfo, abcVersionStr, abcVersion, dateWritten, userInfo, dcc_fps); TESTING_ASSERT( appWriter == appInfo ); TESTING_ASSERT( userStr == userInfo ); TESTING_ASSERT( abcVersion == ALEMBIC_LIBRARY_VERSION ); std::cout << "Alembic version: " << abcVersionStr << std::endl; std::cout << "Date written: " << dateWritten << std::endl; TESTING_ASSERT( dateWritten != "" ); TESTING_ASSERT( abcVersionStr != "" ); TESTING_ASSERT( dcc_fps == 0 ); double start, end; GetArchiveStartAndEndTime( archive, start, end ); TESTING_ASSERT( start == DBL_MAX && end == -DBL_MAX ); } { AbcF::IFactory factory; AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive("archiveInfoWFPS.abc", coreType); TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) || (!useOgawa && coreType == AbcF::IFactory::kHDF5) ); TESTING_ASSERT( archive.getPtr()->getMetaData().get("taco") == "bar" ); TESTING_ASSERT( archive.getPtr()->getMetaData().get("potato") == "salad" ); TESTING_ASSERT( archive.getArchiveVersion() == ALEMBIC_LIBRARY_VERSION ); std::string appInfo; std::string abcVersionStr; Alembic::Util::uint32_t abcVersion = 0; double dcc_fps = 123.0; std::string dateWritten; std::string userInfo; GetArchiveInfo( archive, appInfo, abcVersionStr, abcVersion, dateWritten, userInfo, dcc_fps ); TESTING_ASSERT( appWriter == appInfo ); TESTING_ASSERT( userStr == userInfo ); TESTING_ASSERT( abcVersion == ALEMBIC_LIBRARY_VERSION ); std::cout << "Alembic version: " << abcVersionStr << std::endl; std::cout << "Date written: " << dateWritten << std::endl; TESTING_ASSERT( dateWritten != "" ); TESTING_ASSERT( abcVersionStr != "" ); TESTING_ASSERT( dcc_fps == 42.0 ); double start, end; GetArchiveStartAndEndTime( archive, start, end ); TESTING_ASSERT( start == DBL_MAX && end == -DBL_MAX ); } } void scopingTest(bool useOgawa) { { OObject top; { OArchive archive; if (useOgawa) { archive = CreateArchiveWithInfo( Alembic::AbcCoreOgawa::WriteArchive(), "archiveScopeTest.abc", "Alembic test", "", MetaData() ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = CreateArchiveWithInfo( Alembic::AbcCoreHDF5::WriteArchive(), "archiveScopeTest.abc", "Alembic test", "", MetaData() ); } #endif top = archive.getTop(); } OObject childA( top, "a"); OObject childB( top, "b"); ODoubleProperty prop(top.getProperties(), "prop", 0); TESTING_ASSERT(prop.getObject().getArchive().getName() == "archiveScopeTest.abc"); } { IObject top; { AbcF::IFactory factory; AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive("archiveScopeTest.abc", coreType); TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) || (!useOgawa && coreType == AbcF::IFactory::kHDF5) ); top = archive.getTop(); double start, end; GetArchiveStartAndEndTime( archive, start, end ); TESTING_ASSERT( start == DBL_MAX && end == -DBL_MAX ); } TESTING_ASSERT(top.getNumChildren() == 2 ); TESTING_ASSERT(top.getChildHeader("a") != NULL); TESTING_ASSERT(top.getChildHeader("b") != NULL); TESTING_ASSERT( ! top.getParent().valid() ); TESTING_ASSERT( top.getArchive().getName() == "archiveScopeTest.abc"); IScalarProperty prop(top.getProperties(), "prop"); TESTING_ASSERT(prop.valid()); TESTING_ASSERT(prop.getObject().getArchive().getName() == "archiveScopeTest.abc"); } } int main( int argc, char *argv[] ) { archiveInfoTest(true); scopingTest(true); #ifdef ALEMBIC_WITH_HDF5 archiveInfoTest(false); scopingTest(false); #endif return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/ArrayPropertyTest.cpp000066400000000000000000000660701507001531700232150ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif namespace Abc = Alembic::Abc; namespace AbcF = Alembic::AbcCoreFactory; using namespace Abc; using Alembic::AbcCoreAbstract::chrono_t; using Alembic::AbcCoreAbstract::index_t; using Alembic::Util::uint32_t; // // The tests in this file are intended to exercize the Abc API; // specifically writing and reading of uniformly samples properties // unsigned int g_primes[5] = {2, 3, 5, 7, 11}; Imath::V3f g_vectors[5] = { Imath::V3f(1,1,1), Imath::V3f(2,2,2), Imath::V3f(3,3,3), Imath::V3f(4,4,4), Imath::V3f(5,5,5) }; void writeUInt32ArrayProperty(const std::string &archiveName, bool useOgawa) { const chrono_t dt = 1.0 / 24.0; const chrono_t startTime = 123.0; // Create an archive for writing. Indicate that we want Alembic to // throw exceptions on errors. OArchive archive; if (useOgawa) { archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); } #endif OObject archiveTop = archive.getTop(); // Create a child, parented under the archive std::string name = "child"; OObject child( archiveTop, name ); OCompoundProperty childProps = child.getProperties(); // Create a scalar property on this child object named 'primes' OUInt32ArrayProperty primes( childProps, // owner "primes"); // uniform with cycle=dt std::vector vals; for (int ss=0; ss<5; ss++) { // This vector increases in length as we go, increasing the // extent of each successive sample vals.push_back( g_primes[ss] ); primes.set( vals ); } std::vector < chrono_t > timeSamps(1, startTime); TimeSamplingPtr ts( new TimeSampling(TimeSamplingType( dt ), timeSamps) ); primes.setTimeSampling( ts ); std::cout << archiveName << " was successfully written" << std::endl; // Done - the archive closes itself } void readUInt32ArrayProperty(const std::string &archiveName, bool useOgawa) { // Open an existing archive for reading. Indicate that we want // Alembic to throw exceptions on errors. std::cout << "Reading " << archiveName << std::endl; AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(archiveName, coreType); TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) || (!useOgawa && coreType == AbcF::IFactory::kHDF5) ); IObject archiveTop = archive.getTop(); // Determine the number of (top level) children the archive has const unsigned int numChildren = archiveTop.getNumChildren(); ABCA_ASSERT( numChildren == 1, "Wrong number of children (expected 1)"); std::cout << "The archive has " << numChildren << " children:" << std::endl; // Iterate through them, print out their names IObject child( archiveTop, archiveTop.getChildHeader(0).getName() ); std::cout << " named '" << child.getName() << "'"; // Properties ICompoundProperty props = child.getProperties(); size_t numProperties = props.getNumProperties(); // only top-level props ABCA_ASSERT( numProperties == 1, "Expected 1 property, found " << numProperties); std::cout << " with one property"; std::vector propNames(1); propNames[0] = props.getPropertyHeader(0).getName(); std::cout << " named '" << propNames[0] << "'" << std::endl; PropertyType pType = props.getPropertyHeader(0).getPropertyType(); ABCA_ASSERT( pType == kArrayProperty, "Expected an array property, but didn't find one" ); std::cout << " which is an array property"; DataType dType = props.getPropertyHeader(0).getDataType(); ABCA_ASSERT( dType.getPod() == kUint32POD, "Expected an unsigned int (kUint32POD) property, but didn't" " find one" ); // We know this is an array property (I'm eliding the if/else // statements required to recognize and handle this properly) IUInt32ArrayProperty primes( props, propNames[0] ); size_t numSamples = primes.getNumSamples(); std::cout << ".. it has " << numSamples << " samples" << std::endl; ABCA_ASSERT( numSamples == 5, "Expected 5 samples, found " << numSamples ); const TimeSamplingPtr ts = primes.getTimeSampling(); std::cout << "..with time/value pairs: " << std::endl;; for (unsigned int ss=0; ssgetSampleTime( (index_t) ss ) << " / "; UInt32ArraySamplePtr samplePtr; primes.get( samplePtr, iss ); std::cout << "[ "; size_t numPoints = samplePtr->size(); for ( size_t jj=0 ; jj uintPrimes( numPoints ); primes.getAs( &uintPrimes.front(), iss ); for ( size_t jj=0 ; jj shortPrimes( numPoints ); primes.getAs( &shortPrimes.front(), AbcA::kInt16POD, iss ); for ( size_t jj=0 ; jj timeSamps(1, startTime); TimeSampling ts(TimeSamplingType( dt ), timeSamps); Alembic::Util::uint32_t tsid = archive.addTimeSampling(ts); // Create a scalar property on this child object named 'positions' OV3fArrayProperty positions( childProps, // owner "positions"); std::vector vals; vals.push_back( g_vectors[0] ); positions.set( vals ); vals.push_back( g_vectors[1] ); positions.set( vals ); // The next statement will kill this test with the following error: // terminate called after throwing an instance of 'Alembic::Util::Exception' // what(): OArrayProperty::set() // ERROR: EXCEPTION: // Degenerate array sample in WriteArray // Abort vals.clear(); positions.set( vals ); vals.push_back( g_vectors[0] ); vals.push_back( g_vectors[1] ); vals.push_back( g_vectors[2] ); vals.push_back( g_vectors[3] ); positions.set( vals ); vals.push_back( g_vectors[4] ); positions.set( vals ); std::cout << archiveName << " was successfully written" << std::endl; positions.setTimeSampling(tsid); // Done - the archive closes itself } void readV3fArrayProperty(const std::string &archiveName, bool useOgawa) { // Open an existing archive for reading. Indicate that we want // Alembic to throw exceptions on errors. std::cout << "Reading " << archiveName << std::endl; AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(archiveName, coreType); TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) || (!useOgawa && coreType == AbcF::IFactory::kHDF5) ); IObject archiveTop = archive.getTop(); // Determine the number of (top level) children the archive has const unsigned int numChildren = archiveTop.getNumChildren(); ABCA_ASSERT( numChildren == 1, "Wrong number of children (expected 1)"); std::cout << "The archive has " << numChildren << " children:" << std::endl; // Iterate through them, print out their names IObject child( archiveTop, archiveTop.getChildHeader(0).getName() ); std::cout << " named '" << child.getName() << "'"; // Properties ICompoundProperty props = child.getProperties(); size_t numProperties = props.getNumProperties(); // only top-level props ABCA_ASSERT( numProperties == 1, "Expected 1 property, found " << numProperties); std::cout << " with one property"; std::vector propNames(1); propNames[0] = props.getPropertyHeader(0).getName(); std::cout << " named '" << propNames[0] << "'" << std::endl; PropertyType pType = props.getPropertyHeader(0).getPropertyType(); ABCA_ASSERT( pType == kArrayProperty, "Expected an array property, but didn't find one" ); std::cout << " which is an array property"; DataType dType = props.getPropertyHeader(0).getDataType(); ABCA_ASSERT( dType.getPod() == kFloat32POD, "Expected an v3f property, but didn't find one" ); // We know this is an array property (I'm eliding the if/else // statements required to recognize and handle this properly) IV3fArrayProperty positions( props, propNames[0] ); size_t numSamples = positions.getNumSamples(); std::cout << ".. it has " << numSamples << " samples" << std::endl; ABCA_ASSERT( numSamples == 5, "Expected 5 samples, found " << numSamples ); TimeSamplingPtr ts = positions.getTimeSampling(); std::cout << "..with time/value pairs: " << std::endl;; for (unsigned int ss=0; ssgetSampleTime( (index_t) ss ) << " / "; V3fArraySamplePtr samplePtr; positions.get( samplePtr, iss ); std::cout << "[ "; size_t numPoints = samplePtr->size(); for ( size_t jj=0 ; jj grays(8); grays[0].x = 0.0; grays[0].y = 0.0; grays[0].z = 0.0; grays[1].x = 0.125; grays[1].y = 0.125; grays[1].z = 0.125; grays[2].x = 0.25; grays[2].y = 0.25; grays[2].z = 0.25; grays[3].x = 0.375; grays[3].y = 0.375; grays[3].z = 0.375; grays[4].x = 0.5; grays[4].y = 0.5; grays[4].z = 0.5; grays[5].x = 0.625; grays[5].y = 0.625; grays[5].z = 0.625; grays[6].x = 0.75; grays[6].y = 0.75; grays[6].z = 0.75; grays[7].x = 0.875; grays[7].y = 0.875; grays[7].z = 0.875; // let's write 4 different color3f[2] Dimensions d; d.setRank(2); d[0] = 2; d[1] = 4; C3fArraySample cas(&(grays.front()), d); shades.set(cas); } { // now read it AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(archiveName, coreType); TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) || (!useOgawa && coreType == AbcF::IFactory::kHDF5) ); IObject archiveTop = archive.getTop(); IObject child( archiveTop, archiveTop.getChildHeader(0).getName() ); ICompoundProperty props = child.getProperties(); IC3fArrayProperty shades( props, "shades" ); C3fArraySamplePtr samplePtr; shades.get( samplePtr ); ABCA_ASSERT( samplePtr->getDimensions().rank() == 2, "Incorrect rank on the sample." ); ABCA_ASSERT( samplePtr->getDimensions().numPoints() == 8, "Incorrect number of total points." ); ABCA_ASSERT( samplePtr->getDimensions()[0] == 2, "Incorrect size on dimension 0." ); ABCA_ASSERT( samplePtr->getDimensions()[1] == 4, "Incorrect size on dimension 1." ); Alembic::Util::Dimensions dims; shades.getDimensions( dims ); ABCA_ASSERT( dims.rank() == 2, "Incorrect rank on the sample." ); ABCA_ASSERT( dims.numPoints() == 8, "Incorrect number of total points." ); ABCA_ASSERT( dims[0] == 2, "Incorrect size on dimension 0." ); ABCA_ASSERT( dims[1] == 4, "Incorrect size on dimension 1." ); for (size_t i = 0; i < 8; ++i) { ABCA_ASSERT( (*samplePtr)[i].x == i/8.0 && (*samplePtr)[i].x == (*samplePtr)[i].y && (*samplePtr)[i].x == (*samplePtr)[i].z, "Color [" << i << "] is incorrect."); } double start, end; GetArchiveStartAndEndTime( archive, start, end ); TESTING_ASSERT( almostEqual(start, 0.0) ); TESTING_ASSERT( almostEqual(end, 0.0) ); } } //////////////////////////////////////////////////////////////////////////////// void emptyAndValueTest(const std::string &archiveName, bool useOgawa) { std::vector strVec; strVec.push_back( "potato" ); std::vector colorVec; colorVec.push_back( C3f( 0.0, 0.5, 0.75 ) ); std::vector intVec; intVec.push_back(42); StringArraySample strSamp( strVec ); C3fArraySample colorSamp( colorVec ); Int32ArraySample intSamp( intVec ); StringArraySample emptyStrSamp = StringArraySample::emptySample(); C3fArraySample emptyColorSamp = C3fArraySample::emptySample(); Int32ArraySample emptyIntSamp = Int32ArraySample::emptySample(); { OArchive archive; if (useOgawa) { archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(), archiveName ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(), archiveName ); } #endif OCompoundProperty root = archive.getTop().getProperties(); OC3fArrayProperty colorProp( root, "colors" ); OInt32ArrayProperty numProp( root, "numbers" ); OInt32ArrayProperty numProp2( root, "numbers2" ); OInt32ArrayProperty numProp3( root, "numbers3" ); OInt32ArrayProperty numProp4( root, "numbers4" ); AbcA::MetaData md; SetReference( md ); OStringArrayProperty strProp( root, "strings", md ); TESTING_ASSERT( isReference( strProp.getHeader() ) ); colorProp.set( emptyColorSamp ); colorProp.set( colorSamp ); colorProp.set( emptyColorSamp ); colorProp.set( colorSamp ); numProp.set( emptyIntSamp ); numProp.set( intSamp ); numProp.set( emptyIntSamp ); numProp.set( intSamp ); strProp.set( emptyStrSamp ); strProp.set( strSamp ); strProp.set( emptyStrSamp ); strProp.set( strSamp ); // repeat samples at start numProp2.set( emptyIntSamp ); numProp2.set( emptyIntSamp ); numProp2.set( emptyIntSamp ); numProp2.set( intSamp ); numProp2.set( intSamp ); numProp2.set( emptyIntSamp ); numProp2.set( intSamp ); // repeat samples at end numProp3.set( intSamp ); numProp3.set( emptyIntSamp ); numProp3.set( intSamp ); numProp3.set( intSamp ); numProp3.set( emptyIntSamp ); numProp3.set( emptyIntSamp ); numProp3.set( emptyIntSamp ); // repeat at start and end numProp4.set( emptyIntSamp ); numProp4.set( emptyIntSamp ); numProp4.set( intSamp ); numProp4.set( intSamp ); numProp4.set( emptyIntSamp ); numProp4.set( emptyIntSamp ); } { StringArraySamplePtr strSampPtr; C3fArraySamplePtr colorSampPtr; Int32ArraySamplePtr intSampPtr; AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(archiveName, coreType); TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) || (!useOgawa && coreType == AbcF::IFactory::kHDF5) ); ICompoundProperty root = archive.getTop().getProperties(); IC3fArrayProperty colorProp( root, "colors" ); IInt32ArrayProperty numProp( root, "numbers" ); IStringArrayProperty strProp( root, "strings" ); IInt32ArrayProperty numProp2( root, "numbers2" ); IInt32ArrayProperty numProp3( root, "numbers3" ); IInt32ArrayProperty numProp4( root, "numbers4" ); TESTING_ASSERT( isReference( strProp.getHeader() ) ); TESTING_ASSERT( colorProp.getNumSamples() == 4 ); TESTING_ASSERT( strProp.getNumSamples() == 4 ); TESTING_ASSERT( numProp.getNumSamples() == 4 ); colorProp.get( colorSampPtr, 0 ); strProp.get( strSampPtr, 0 ); numProp.get( intSampPtr, 0 ); TESTING_ASSERT( colorSampPtr->size() == 0 ); TESTING_ASSERT( strSampPtr->size() == 0 ); TESTING_ASSERT( intSampPtr->size() == 0 ); colorProp.get( colorSampPtr, 2 ); strProp.get( strSampPtr, 2 ); numProp.get( intSampPtr, 2 ); TESTING_ASSERT( colorSampPtr->size() == 0 ); TESTING_ASSERT( strSampPtr->size() == 0 ); TESTING_ASSERT( intSampPtr->size() == 0 ); colorProp.get( colorSampPtr, 1 ); strProp.get( strSampPtr, 1 ); numProp.get( intSampPtr, 1 ); TESTING_ASSERT( colorSampPtr->size() == 1 && colorSamp[0] == ( *colorSampPtr )[0] ); TESTING_ASSERT( strSampPtr->size() == 1 && strSamp[0] == ( *strSampPtr )[0] ); TESTING_ASSERT( intSampPtr->size() == 1 && intSamp[0] == ( *intSampPtr )[0] ); colorProp.get( colorSampPtr, 3 ); strProp.get( strSampPtr, 3 ); numProp.get( intSampPtr, 3 ); TESTING_ASSERT( colorSampPtr->size() == 1 && colorSamp[0] == ( *colorSampPtr )[0] ); TESTING_ASSERT( strSampPtr->size() == 1 && strSamp[0] == ( *strSampPtr )[0] ); TESTING_ASSERT( intSampPtr->size() == 1 && intSamp[0] == ( *intSampPtr )[0] ); numProp2.get( intSampPtr, 0 ); TESTING_ASSERT( intSampPtr->size() == 0 ); numProp2.get( intSampPtr, 1 ); TESTING_ASSERT( intSampPtr->size() == 0 ); numProp2.get( intSampPtr, 2 ); TESTING_ASSERT( intSampPtr->size() == 0 ); numProp2.get( intSampPtr, 3 ); TESTING_ASSERT( intSampPtr->size() == 1 ); numProp2.get( intSampPtr, 4 ); TESTING_ASSERT( intSampPtr->size() == 1 ); numProp2.get( intSampPtr, 5 ); TESTING_ASSERT( intSampPtr->size() == 0 ); numProp2.get( intSampPtr, 6 ); TESTING_ASSERT( intSampPtr->size() == 1 ); numProp3.get( intSampPtr, 0 ); TESTING_ASSERT( intSampPtr->size() == 1 ); numProp3.get( intSampPtr, 1 ); TESTING_ASSERT( intSampPtr->size() == 0 ); numProp3.get( intSampPtr, 2 ); TESTING_ASSERT( intSampPtr->size() == 1 ); numProp3.get( intSampPtr, 3 ); TESTING_ASSERT( intSampPtr->size() == 1 ); numProp3.get( intSampPtr, 4 ); TESTING_ASSERT( intSampPtr->size() == 0 ); numProp3.get( intSampPtr, 5 ); TESTING_ASSERT( intSampPtr->size() == 0 ); numProp3.get( intSampPtr, 6 ); TESTING_ASSERT( intSampPtr->size() == 0 ); numProp4.get( intSampPtr, 0 ); TESTING_ASSERT( intSampPtr->size() == 0 ); numProp4.get( intSampPtr, 1 ); TESTING_ASSERT( intSampPtr->size() == 0 ); numProp4.get( intSampPtr, 2 ); TESTING_ASSERT( intSampPtr->size() == 1 ); numProp4.get( intSampPtr, 3 ); TESTING_ASSERT( intSampPtr->size() == 1 ); numProp4.get( intSampPtr, 4 ); TESTING_ASSERT( intSampPtr->size() == 0 ); numProp4.get( intSampPtr, 5 ); TESTING_ASSERT( intSampPtr->size() == 0 ); } } int main( int argc, char *argv[] ) { // Write and read a simple archive: one child, with one array // property bool useOgawa = true; try { // An array of v3fs, written with uniform sampling, some of which // are empty std::string archiveName("v3f_array_test.abc"); useOgawa = true; writeV3fArrayProperty ( archiveName, useOgawa ); readV3fArrayProperty ( archiveName, useOgawa ); #ifdef ALEMBIC_WITH_HDF5 useOgawa = false; writeV3fArrayProperty ( archiveName, useOgawa ); readV3fArrayProperty ( archiveName, useOgawa ); #endif } catch (char * str ) { std::cout << "Exception raised: " << str; std::cout << " during UInt array, uniform sampling test "; if ( useOgawa ) { std::cout << "with Ogawa" << std::endl; } else { std::cout << "with HDF5" << std::endl; } return 1; } readWriteColorArrayProperty( "c3_2_array_test.abc", true ); emptyAndValueTest( "empty_and_value_prop_test.abc", true ); #ifdef ALEMBIC_WITH_HDF5 readWriteColorArrayProperty( "c3_2_array_test.abc", false ); emptyAndValueTest( "empty_and_value_prop_test.abc", false ); #endif try { // An array of unsigned ints, written with uniform sampling std::string archiveName("uint_array_test.abc"); useOgawa = true; writeUInt32ArrayProperty ( archiveName, useOgawa ); readUInt32ArrayProperty ( archiveName, useOgawa); #ifdef ALEMBIC_WITH_HDF5 useOgawa = false; writeUInt32ArrayProperty ( archiveName, useOgawa ); readUInt32ArrayProperty ( archiveName, useOgawa); #endif } catch (char * str ) { std::cout << "Exception raised: " << str; std::cout << " during UInt array, uniform sampling test "; if ( useOgawa ) { std::cout << "with Ogawa" << std::endl; } else { std::cout << "with HDF5" << std::endl; } return 1; } return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/CMakeLists.txt000066400000000000000000000107101507001531700215540ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib) ADD_EXECUTABLE(Abc_Test1 test1.cpp) TARGET_LINK_LIBRARIES(Abc_Test1 Alembic) ADD_EXECUTABLE(Abc_ObjectsAndProperties_Test2 ObjectsAndPropertiesTest.cpp) TARGET_LINK_LIBRARIES(Abc_ObjectsAndProperties_Test2 Alembic) ADD_TEST(Abc_TEST1 Abc_Test1) ADD_TEST(Abc_Objects_and_Properties_TEST2 Abc_ObjectsAndProperties_Test2) ADD_EXECUTABLE(Abc_CompileTests CompileTest.cpp) TARGET_LINK_LIBRARIES(Abc_CompileTests Alembic) ADD_TEST(Abc_Compile_TEST Abc_CompileTests) ADD_EXECUTABLE(Abc_ObjectTests ObjectTests.cpp) TARGET_LINK_LIBRARIES(Abc_ObjectTests Alembic) ADD_TEST(Abc_Object_TEST Abc_ObjectTests) ADD_EXECUTABLE(Abc_PropertyTests PropertyTests.cpp) TARGET_LINK_LIBRARIES(Abc_PropertyTests Alembic) ADD_TEST(Abc_Property_TEST Abc_PropertyTests) ADD_EXECUTABLE(Abc_UniformPropertyTest UniformPropertyTest.cpp) TARGET_LINK_LIBRARIES(Abc_UniformPropertyTest Alembic) ADD_TEST(Abc_Uniform_Property_TEST Abc_UniformPropertyTest) ADD_EXECUTABLE(Abc_IdentityPropertyTest IdentityPropertyTest.cpp) TARGET_LINK_LIBRARIES(Abc_IdentityPropertyTest Alembic) ADD_TEST(Abc_Identity_Property_TEST Abc_IdentityPropertyTest) ADD_EXECUTABLE(Abc_ArrayPropertyTest ArrayPropertyTest.cpp) TARGET_LINK_LIBRARIES(Abc_ArrayPropertyTest Alembic) ADD_TEST(Abc_Array_Property_TEST Abc_ArrayPropertyTest) ADD_EXECUTABLE(Abc_InstanceTest InstanceTest.cpp) TARGET_LINK_LIBRARIES(Abc_InstanceTest Alembic) ADD_TEST(Abc_Instance_TEST Abc_InstanceTest) ADD_EXECUTABLE(Abc_ArchiveTest ArchiveTest.cpp) TARGET_LINK_LIBRARIES(Abc_ArchiveTest Alembic) ADD_TEST(Abc_Archive_TEST Abc_ArchiveTest) ADD_EXECUTABLE(Abc_CyclicPropertyTest CyclicPropertyTest.cpp) TARGET_LINK_LIBRARIES(Abc_CyclicPropertyTest Alembic) ADD_TEST(Abc_Cyclic_Property_TEST Abc_CyclicPropertyTest) ADD_EXECUTABLE(Abc_ParentingTest ParentingTest.cpp) TARGET_LINK_LIBRARIES(Abc_ParentingTest Alembic) ADD_TEST(Abc_Parenting_TEST Abc_ParentingTest) ADD_EXECUTABLE(Abc_OctessenceBug17 OctessenceBug17.cpp) TARGET_LINK_LIBRARIES(Abc_OctessenceBug17 Alembic) ADD_TEST(Abc_OctessenceBug17_TEST Abc_OctessenceBug17) ADD_EXECUTABLE(Abc_OctessenceBug16 OctessenceBug16.cpp) TARGET_LINK_LIBRARIES(Abc_OctessenceBug16 Alembic) ADD_TEST(Abc_OctessenceBug16_TEST Abc_OctessenceBug16) ADD_EXECUTABLE(Abc_CacheControlTest CacheControlTest.cpp) TARGET_LINK_LIBRARIES(Abc_CacheControlTest Alembic) ADD_TEST(Abc_CacheControl_TEST Abc_CacheControlTest) ADD_EXECUTABLE(Abc_RedundantDataPathsTest RedundantDataTest.cpp) TARGET_LINK_LIBRARIES(Abc_RedundantDataPathsTest Alembic) ADD_TEST(Abc_RedundantDataPaths_TEST Abc_RedundantDataPathsTest) file(COPY fuzzer_issue26643.abc DESTINATION .) alembic-1.8.9/lib/Alembic/Abc/Tests/CacheControlTest.cpp000066400000000000000000000103161507001531700227260ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif namespace Abc = Alembic::Abc; using namespace Abc; //-***************************************************************************** // This test is mostly a compile test at this time - I want to demonstrate // the different ways of expressing the cache to the IArchives int main( int argc, char *argv[] ) { #ifdef ALEMBIC_WITH_HDF5 std::string iArchiveBaseName = "oooooooh_ca-aache_controoo-ool_oooh_oh"; for ( size_t i = 0 ; i < 3 ; i++ ) { std::string iArchiveName = iArchiveBaseName; char a = 'a' + i; iArchiveName += a ; iArchiveName.append( ".abc" ); OArchive archive( Alembic::AbcCoreHDF5::WriteArchive(), iArchiveName ); // all child Objects in an Archive are actually children of the single // top Object in an Archive OObject topobj = archive.getTop(); // 0th archive child OObject ac0( topobj, "ac0" ); // 0th archive child child OObject acc0( ac0, "acc0" ); } for ( size_t i = 0 ; i < 3 ; i++ ) { std::string iArchiveName = iArchiveBaseName; char a = 'a' + i; iArchiveName += a ; iArchiveName.append( ".abc" ); if ( i == 0 ) { // Explicitly specify the implementation and the file name. // A cache is created automatically. IArchive archive1( Alembic::AbcCoreHDF5::ReadArchive(), iArchiveName ); } if ( i == 1 ) { // Create an implementation with a NULL cache. IArchive archive2( Alembic::AbcCoreHDF5::ReadArchive(), iArchiveName, ErrorHandler::kThrowPolicy, ReadArraySampleCachePtr() ); } if ( i == 2 ) { // Create an implementation with a cache from elsewhere ReadArraySampleCachePtr externalCache = Alembic::AbcCoreHDF5::CreateCache(); IArchive archive3( Alembic::AbcCoreHDF5::ReadArchive(), iArchiveName, ErrorHandler::kThrowPolicy, externalCache ); } } #endif return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/CompileTest.cpp000066400000000000000000000214021507001531700217500ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif using namespace Alembic::Abc; // A bunch of minimal compile tests to make sure the templates compile // Declare a test schema. ALEMBIC_ABC_DECLARE_SCHEMA_INFO( "TestSchema_v1", "", ".test", false, TestSchemaInfo ); typedef OSchema OTestSchema; typedef OSchemaObject OTest; typedef ISchema ITestSchema; typedef ISchemaObject ITest; void testOSchemaObject( OObject &iParent ) { OTest tst( iParent, "childTestObject" ); OTest tst2( tst.getPtr(), "foo", ErrorHandler::kQuietNoopPolicy ); OTest tst3( tst2.getPtr(), "bar", kNoMatching ); OTest tst4( tst3, "baz", ErrorHandler::kNoisyNoopPolicy, kStrictMatching ); OTestSchema& schm = tst4.getSchema(); schm.valid(); } void testOSchema( OObject & iParent ) { OTestSchema tst( OCompoundProperty( iParent, kTop ), OTestSchema::getDefaultSchemaName() ); OTestSchema tst2( tst, "foo", ErrorHandler::kQuietNoopPolicy ); OTestSchema tst3( tst2, "bar", kNoMatching ); OTestSchema tst4( tst3, "baz", ErrorHandler::kNoisyNoopPolicy, kStrictMatching ); } void testISchemaObject( IObject & iParent ) { ITest tst( iParent, "childTestObject" ); ITest tst2( tst, ErrorHandler::kQuietNoopPolicy ); ITest tst3( tst2, kNoMatching ); ITest tst4( tst3, kWrapExisting, ErrorHandler::kNoisyNoopPolicy, kStrictMatching ); ITestSchema& schm = tst4.getSchema(); schm.valid(); } void testISchema( IObject &iParent ) { ITestSchema tst( ICompoundProperty( iParent, kTop ) ); std::cout << "isNull? " << int( tst.getPtr() == NULL ) << std::endl; ITestSchema tst2( tst.getPtr(), ErrorHandler::kQuietNoopPolicy ); std::cout << "isNull? " << int( tst2.getPtr() == NULL ) << std::endl; ITestSchema tst3( tst2.getPtr(), kNoMatching ); ITestSchema tst4( tst3, ErrorHandler::kNoisyNoopPolicy, kStrictMatching ); } void testOTypedScalarProperty( OObject &iObject ) { OBoolProperty boolProp( OCompoundProperty( iObject, kTop ), "boolPropScalar" ); OInt32Property intProp( OCompoundProperty( iObject, kTop ), "intPropScalar" ); OInt32Property intProp2( intProp.getPtr(), kWrapExisting ); intProp.set( 5 ); intProp2.set( 6 ); boolProp.set( false ); } void testOTypedArrayProperty( OObject &iObject ) { OBoolArrayProperty boolProp( OCompoundProperty( iObject, kTop ), "boolPropArray" ); OInt32ArrayProperty intProp( OCompoundProperty( iObject, kTop ), "intPropArray" ); OInt32ArrayProperty intProp2( intProp.getPtr(), kWrapExisting ); Alembic::Util::int32_t i[] = { 1, 2, 3, 4, 5 }; intProp.set( Int32ArraySample( i, 5 ) ); intProp2.set( Int32ArraySample( i, 5 ) ); std::vector bools( 17 ); boolProp.set( bools ); } void testITypedScalarProperty( IObject &iObject ) { IBoolProperty boolProp( ICompoundProperty( iObject, kTop ), "boolPropScalar" ); IInt32Property intProp( ICompoundProperty( iObject, kTop ), "intPropScalar" ); IInt32Property intProp2( intProp.getPtr(), kWrapExisting ); Alembic::Util::int32_t i; intProp.get( i ); intProp2.get( i, 1 ); Alembic::Util::bool_t b; boolProp.get( b ); } void testITypedArrayProperty( IObject &iObject ) { IBoolArrayProperty boolProp( ICompoundProperty( iObject, kTop ), "boolPropArray" ); IInt32ArrayProperty intProp( ICompoundProperty( iObject, kTop ), "intPropArray" ); IInt32ArrayProperty intProp2( intProp.getPtr(), kWrapExisting ); Int32ArraySamplePtr iPtr; intProp.get( iPtr ); intProp2.get( iPtr, 1 ); BoolArraySamplePtr bPtr; boolProp.get( bPtr ); } void testInstancedSchema() { { OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), "instancedTest.abc" ); OObject archiveTop = archive.getTop(); OObject a( archiveTop, "a" ); OTest aa( a, "a" ); OObject b( archiveTop, "b" ); b.addChildInstance( aa, "bb" ); } { IArchive archive( Alembic::AbcCoreOgawa::ReadArchive(), "instancedTest.abc" ); IObject archiveTop = archive.getTop(); IObject b( archiveTop, "b" ); IObject bb( b, "bb" ); ITest bb1( b, "bb" ); ITest bb2( bb ); ABCA_ASSERT( bb.getName() == bb1.getName(), "Instanced bb and bb1 names don't match." ); ABCA_ASSERT( bb.getName() == bb2.getName(), "Instanced bb and bb1 names don't match." ); ABCA_ASSERT( bb.getFullName() == "/b/bb", "Bad full name for bb" ); ABCA_ASSERT( bb1.getFullName() == "/b/bb", "Bad full name for bb1" ); ABCA_ASSERT( bb2.getFullName() == "/b/bb", "Bad full name for bb2" ); } } int main( int argc, char *argv[] ) { std::string archiveName = "compile_test.abc"; #ifdef ALEMBIC_WITH_HDF5 { OArchive archive( Alembic::AbcCoreHDF5::WriteArchive(), archiveName, ErrorHandler::kNoisyNoopPolicy ); OObject archiveTop = archive.getTop(); testOSchemaObject( archiveTop ); OObject child( archiveTop, "otherChild" ); testOSchema( child ); testOTypedScalarProperty( child ); testOTypedArrayProperty( child ); } { IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(), archiveName, ErrorHandler::kNoisyNoopPolicy ); IObject archiveTop = archive.getTop(); testISchemaObject( archiveTop ); IObject child( archiveTop, "otherChild" ); testISchema( child ); testITypedScalarProperty( child ); testITypedArrayProperty( child ); } #endif { OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), archiveName, ErrorHandler::kNoisyNoopPolicy ); OObject archiveTop = archive.getTop(); testOSchemaObject( archiveTop ); OObject child( archiveTop, "otherChild" ); testOSchema( child ); testOTypedScalarProperty( child ); testOTypedArrayProperty( child ); } { IArchive archive( Alembic::AbcCoreOgawa::ReadArchive(), archiveName, ErrorHandler::kNoisyNoopPolicy ); IObject archiveTop = archive.getTop(); testISchemaObject( archiveTop ); IObject child( archiveTop, "otherChild" ); testISchema( child ); testITypedScalarProperty( child ); testITypedArrayProperty( child ); } testInstancedSchema(); return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/CyclicPropertyTest.cpp000066400000000000000000000206451507001531700233430ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif namespace AbcF = Alembic::AbcCoreFactory; namespace Abc = Alembic::Abc; using namespace Abc; const chrono_t g_startTime = 123.0; const chrono_t g_dt = 1.0 / 24.0; // // The tests in this file are intended to exercize the Abc API; // specifically writing and reading of cyclically sampled properties // void writeProperty(const std::string &archiveName, bool useOgawa) { unsigned int numSamples = 5; // Create an archive for writing. Indicate that we want Alembic to // throw exceptions on errors. OArchive archive; if ( useOgawa ) { archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); } #endif OObject archiveTop = archive.getTop(); // Create a child, parented under the archive std::string name = "child"; OObject child( archiveTop, name ); OCompoundProperty childProps = child.getProperties(); // Create cyclic time sampling std::vector tvec; tvec.push_back( g_startTime ); tvec.push_back( g_startTime + g_dt/3.0 ); tvec.push_back( g_startTime + 2.0*g_dt/3.0 ); const chrono_t timePerCycle = g_dt; const size_t numSamplesPerCycle = 3; numSamples *= numSamplesPerCycle; const TimeSamplingType tSampTyp( numSamplesPerCycle, timePerCycle ); TimeSamplingPtr ts( new TimeSampling( tSampTyp, tvec ) ); // Create a scalar property on this child object named 'mass' // with metadata that indicates it's expressed in kilograms MetaData units; units.set( "units", "kilogram" ); ODoubleProperty mass( childProps, // owner "mass", // name units, ts ); // cyclic, specified above for (unsigned int tt=0; tt void printSampleValue( PROPERTY_CLASS& iProp, const ISampleSelector &iSS ) { std::cout << iProp.getValue( iSS ) << " "; } void readProperty(const std::string &archiveName, bool useOgawa) { // Open an existing archive for reading. Indicate that we want // Alembic to throw exceptions on errors. std::cout << "Reading " << archiveName << std::endl; AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(archiveName, coreType); ABCA_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) || (!useOgawa && coreType == AbcF::IFactory::kHDF5), "File did not open as the expected type." ); IObject archiveTop = archive.getTop(); // Determine the number of (top level) children the archive has const unsigned int numChildren = archiveTop.getNumChildren(); ABCA_ASSERT( numChildren == 1, "Wrong number of children (expected 1)"); std::cout << "The archive has " << numChildren << " children:" << std::endl; // Iterate through them, print out their names IObject child( archiveTop, archiveTop.getChildHeader( 0 ).getName() ); std::cout << " " << child.getName(); // Properties ICompoundProperty props = child.getProperties(); size_t numProperties = props.getNumProperties(); // only top-level props ABCA_ASSERT( numProperties == 1, "Expected 1 property, found " << numProperties); std::cout << " with one property"; std::vector propNames(1); propNames[0] = props.getPropertyHeader(0).getName(); std::cout << " named " << propNames[0] << std::endl; PropertyType pType = props.getPropertyHeader(0).getPropertyType(); ABCA_ASSERT( pType == kScalarProperty, "Expected a scalar property, but didn't find one" ); std::cout << " which is a scalar property"; DataType dType = props.getPropertyHeader(0).getDataType(); ABCA_ASSERT( dType.getPod() == kFloat64POD, "Expected a double (kFloat64POD) property, but didn't" " find one" ); // We know this is a scalar property (I'm eliding the if/else // statements required to recognize this) IDoubleProperty mass( props, propNames[0] ); size_t numSamples = mass.getNumSamples(); std::cout << ".. it has " << numSamples << " samples" << std::endl; //ABCA_ASSERT( numSamples == 5, "Expected 5 samples, found " << numSamples ); TimeSamplingPtr ts = mass.getTimeSampling(); std::cout << "..with time/value pairs: "; for (unsigned int ss=0; ssgetSampleTime( (index_t) ss ) << "/"; printSampleValue( mass, iss ); std::cout << " "; double timeDiff = ts->getSampleTime( (index_t) ss ) - (g_startTime + (ss*(g_dt/3.0))); ABCA_ASSERT( fabs(timeDiff) < 1e-12, "Incorrect sample time read" ); double massDiff = mass.getValue( iss ) - (1.0 + 0.1*ss); ABCA_ASSERT( fabs(massDiff) < 1e-12, "Incorrect sample value read" ); } ABCA_ASSERT( archive.getMaxNumSamplesForTimeSamplingIndex(1) == (index_t) numSamples, "Incorrect number of max samples for Time Sampling ID 1."); std::cout << std::endl; // Done - the archive closes itself } int main( int argc, char *argv[] ) { // Write and read a simple archive: ten children, each with one // simple property bool useOgawa = false; try { std::string archiveName("cyclic_sampling_test.abc"); #ifdef ALEMBIC_WITH_HDF5 writeProperty ( archiveName, useOgawa ); readProperty ( archiveName, useOgawa ); #endif useOgawa = true; writeProperty ( archiveName, useOgawa ); readProperty ( archiveName, useOgawa ); } catch (char * str ) { std::cout << "Exception raised: " << str; std::cout << " during cyclic sampling test "; if ( useOgawa ) { std::cout << "using Ogawa" << std::endl; } else { std::cout << "using HDF5" << std::endl; } return 1; } return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/IdentityPropertyTest.cpp000066400000000000000000000161231507001531700237220ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif namespace Abc = Alembic::Abc; using namespace Abc; namespace AbcF = Alembic::AbcCoreFactory; // // The tests in this file are intended to exercize the Abc API; // specifically writing and reading of default sampled // properties // void writeProperty(const std::string &archiveName, bool useOgawa) { const unsigned int numSamples = 5; // Create an archive for writing. Indicate that we want Alembic to // throw exceptions on errors. OArchive archive; if (useOgawa) { archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); } #endif OObject archiveTop = archive.getTop(); // Create a child, parented under the archive std::string name = "child"; OObject child( archiveTop, name ); OCompoundProperty childProps = child.getProperties(); // Create a scalar property on this child object named 'mass' // with metadata that indicates it's expressed in kilograms MetaData units; units.set( "units", "kilogram" ); ODoubleProperty mass( childProps, // owner "mass", // name units ); // metadata for (unsigned int tt=0; tt void printSampleValue( PROPERTY_CLASS& iProp, const ISampleSelector &iSS ) { std::cout << iProp.getValue( iSS ) << " "; } void readProperty(const std::string &archiveName) { // Open an existing archive for reading. Indicate that we want // Alembic to throw exceptions on errors. std::cout << "Reading " << archiveName << std::endl; AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(archiveName, coreType); IObject archiveTop = archive.getTop(); // Determine the number of (top level) children the archive has const unsigned int numChildren = archiveTop.getNumChildren(); ABCA_ASSERT( numChildren == 1, "Wrong number of children (expected 3)"); std::cout << "The archive has " << numChildren << " children:" << std::endl; // Iterate through them, print out their names IObject child( archiveTop, archiveTop.getChildHeader(0).getName() ); std::cout << " " << child.getName(); // Properties ICompoundProperty props = child.getProperties(); size_t numProperties = props.getNumProperties(); // only top-level props ABCA_ASSERT( numProperties == 1, "Expected 1 property, found " << numProperties); std::cout << " has a simple property"; std::vector propNames(1); propNames[0] = props.getPropertyHeader(0).getName(); std::cout << " named " << propNames[0] << std::endl; PropertyType pType = props.getPropertyHeader(0).getPropertyType(); ABCA_ASSERT( pType == kScalarProperty, "Expected a scalar property, but didn't find one" ); DataType dType = props.getPropertyHeader(0).getDataType(); ABCA_ASSERT( dType.getPod() == kFloat64POD, "Expected a double (kFloat64POD) property, but didn't" " find one" ); // We know this is a scalar property (I'm eliding the if/else // statements required to recognize this) IDoubleProperty mass( props, propNames[0] ); size_t numSamples = mass.getNumSamples(); std::cout << ".. it has " << numSamples << " samples" << std::endl; ABCA_ASSERT( numSamples == 5, "Expected 5 samples, found " << numSamples ); std::cout << "..with values: "; for (unsigned int ss=0; ss #include #include #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif namespace Abc = Alembic::Abc; using namespace Abc; namespace AbcF = Alembic::AbcCoreFactory; using Alembic::AbcCoreAbstract::chrono_t; using Alembic::AbcCoreAbstract::index_t; using Alembic::Util::uint32_t; using Alembic::Util::float32_t; //-***************************************************************************** void simpleTestOut( const std::string& iArchiveName, bool useOgawa ) { OArchive archive; if (useOgawa) { archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); } #endif /* x1 / | \ x2 x3 x2a (x2a is an instance targeting x2) | | x4 x5 (x5 is an instance targeting x4) / | g1 g2 | g5 */ // all child Objects in an Archive are actually children of the single // top Object in an Archive OObject topobj = archive.getTop(); OObject x1( topobj, "x1" ); OObject x2( x1, "x2" ); OObject x3( x1, "x3" ); OObject x4( x2, "x4" ); OObject g1( x4, "g1" ); OObject g2( x4, "g2" ); OObject g5( g2, "g5" ); // x5 is an instance targeting x4 TESTING_ASSERT( x3.addChildInstance( x4, "x5" ) ); // proxies can't point at ancestors (would create a cycle) TESTING_ASSERT( !x2.addChildInstance( x2, "x" ) ); TESTING_ASSERT( !x2.addChildInstance( x1, "x" ) ); // x2a is an instance targeting x2 TESTING_ASSERT( x1.addChildInstance( x2, "x2a" ) ); const Alembic::AbcCoreAbstract::ObjectHeader& x5h = x3.getChildHeader(0); TESTING_ASSERT( x5h.getFullName() == std::string("/x1/x3/x5") ); const Alembic::AbcCoreAbstract::MetaData& md = x5h.getMetaData(); TESTING_ASSERT( md.get("isInstance") == std::string("1") ); const Alembic::AbcCoreAbstract::ObjectHeader& x2ah = x1.getChildHeader(2); TESTING_ASSERT( x2ah.getFullName() == std::string("/x1/x2a") ); const Alembic::AbcCoreAbstract::MetaData& md2 = x2ah.getMetaData(); TESTING_ASSERT( md2.get("isInstance") == std::string("1") ); } //-***************************************************************************** void simpleTestIn( const std::string& iArchiveName ) { AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive( iArchiveName, coreType ); /* x1 / | \ x2 x3 x2a (x2a is an instance targeting x2) | | x4 x5 (x5 is an instance targeting x4) / | g1 g2 | g5 */ // an archive has a single top object which contains all its children IObject topObject = archive.getTop(); IObject x1( topObject, "x1" ); TESTING_ASSERT( x1 != 0 ); // // Verify the target path IObject x2( x1, "x2" ); TESTING_ASSERT( x2.valid() ); TESTING_ASSERT( !x2.isInstanceDescendant() ); IObject x4( x2, "x4" ); TESTING_ASSERT( x4.valid() ); TESTING_ASSERT( !x4.isInstanceDescendant() ); int numChildren = x4.getNumChildren(); TESTING_ASSERT( numChildren == 2 ); TESTING_ASSERT( x4.getParent().getFullName() == x2.getFullName() ); IObject g1( x4.getChild(0) ); TESTING_ASSERT( g1 != 0 ); TESTING_ASSERT( g1.getName() == "g1" ); TESTING_ASSERT( !g1.isInstanceDescendant() ); TESTING_ASSERT( g1.getParent() != 0 ); TESTING_ASSERT( g1.getParent().getFullName() == x4.getFullName() ); IObject g2( x4.getChild(1) ); TESTING_ASSERT( g2 != 0 ); TESTING_ASSERT( g2.getName() == "g2" ); TESTING_ASSERT( !g2.isInstanceDescendant() ); TESTING_ASSERT( g2.getParent() != 0 ); TESTING_ASSERT( g2.getParent().getFullName() == x4.getFullName() ); IObject g5( g2.getChild(0) ); TESTING_ASSERT( g5 != 0 ); TESTING_ASSERT( g5.getName() == "g5" ); TESTING_ASSERT( !g5.isInstanceDescendant() ); TESTING_ASSERT( g5.getParent() != 0 ); TESTING_ASSERT( g5.getParent().getFullName() == g2.getFullName() ); // // Verify the instance path IObject x3( x1, "x3" ); TESTING_ASSERT( x3 != 0 ); IObject x5( x3, "x5" ); TESTING_ASSERT( x5 != 0 ); TESTING_ASSERT( x5.isInstanceDescendant() ); TESTING_ASSERT( x5.isInstanceRoot() ); TESTING_ASSERT( x5.instanceSourcePath() == x4.getFullName() ); TESTING_ASSERT( x5.getName() == "x5" ); IObject x5Copy = x5; TESTING_ASSERT( x5Copy.getName() == "x5" ); numChildren = x5.getNumChildren(); TESTING_ASSERT( numChildren == 2 ); TESTING_ASSERT( x5.getParent().getFullName() == x3.getFullName() ); IObject g1p( x5.getChild(0) ); TESTING_ASSERT( g1p != 0 ); TESTING_ASSERT( g1p.getName() == "g1" ); TESTING_ASSERT( g1p.isInstanceDescendant() ); TESTING_ASSERT( !g1p.isInstanceRoot() ); TESTING_ASSERT( g1p.getParent() != 0 ); TESTING_ASSERT( g1p.getParent().getFullName() == x5.getFullName() ); IObject g2p( x5.getChild(1) ); TESTING_ASSERT( g2p != 0 ); TESTING_ASSERT( g2p.getName() == "g2" ); TESTING_ASSERT( g2p.isInstanceDescendant() ); TESTING_ASSERT( !g2p.isInstanceRoot() ); TESTING_ASSERT( g2p.getParent() != 0 ); TESTING_ASSERT( g2p.getParent().getFullName() == x5.getFullName() ); IObject g5p( g2p.getChild(0) ); TESTING_ASSERT( g5p != 0 ); TESTING_ASSERT( g5p.getName() == "g5" ); TESTING_ASSERT( g5p.isInstanceDescendant() ); TESTING_ASSERT( !g5p.isInstanceRoot() ); TESTING_ASSERT( g5p.getParent() != 0 ); TESTING_ASSERT( g5p.getParent().getFullName() == g2p.getFullName() ); // test x2a IObject x2a( x1, "x2a" ); TESTING_ASSERT( x2a.valid() ); TESTING_ASSERT( x2a.isInstanceDescendant() ); TESTING_ASSERT( x2a.isInstanceRoot() ); TESTING_ASSERT( x2a.instanceSourcePath() == x2.getFullName() ); TESTING_ASSERT( x2a.getNumChildren() == 1 ); IObject x2aParent = x2a.getParent(); TESTING_ASSERT( x2aParent.getFullName() == "/x1" ); TESTING_ASSERT( !x2aParent.isInstanceDescendant() ); } //-***************************************************************************** void diabolicalInstance( const std::string& iArchiveName, bool useOgawa ) { /* a0 b0 (points to a0) / | a1 b1 (points to a1) / | a2 b2 (points to b2) */ { OArchive archive; if (useOgawa) { archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); } #endif OObject topobj = archive.getTop(); OObject a0( topobj, "a0" ); TESTING_ASSERT( topobj.addChildInstance( a0, "b0" ) ); OObject a1( a0, "a1" ); TESTING_ASSERT( a0.addChildInstance( a1, "b1" ) ); OObject a2( a1, "a2" ); TESTING_ASSERT( a1.addChildInstance( a2, "b2" ) ); } { AbcF::IFactory factory; IArchive archive = factory.getArchive( iArchiveName ); IObject topObject = archive.getTop(); IObject a0( topObject.getChild(0) ); TESTING_ASSERT( !a0.isInstanceDescendant() ); TESTING_ASSERT( a0.getFullName() == "/a0" ); TESTING_ASSERT( !a0.getParent().isInstanceDescendant() ); TESTING_ASSERT( a0.getParent().getFullName() == "/" ); IObject b0( topObject.getChild(1) ); TESTING_ASSERT( b0.isInstanceDescendant() ); TESTING_ASSERT( b0.getName() == "b0" ); TESTING_ASSERT( b0.getFullName() == "/b0" ); TESTING_ASSERT( !b0.getParent().isInstanceDescendant() ); TESTING_ASSERT( b0.getParent().getFullName() == "/" ); IObject a0a1( a0.getChild(0) ); TESTING_ASSERT( !a0a1.isInstanceDescendant() ); TESTING_ASSERT( a0a1.getName() == "a1" ); TESTING_ASSERT( a0a1.getFullName() == "/a0/a1" ); TESTING_ASSERT( !a0a1.getParent().isInstanceDescendant() ); TESTING_ASSERT( a0a1.getParent().getName() == "a0" ); TESTING_ASSERT( a0a1.getParent().getFullName() == "/a0" ); IObject a0b1( a0.getChild(1) ); TESTING_ASSERT( a0b1.isInstanceDescendant() ); TESTING_ASSERT( a0b1.getName() == "b1" ); TESTING_ASSERT( a0b1.getFullName() == "/a0/b1" ); TESTING_ASSERT( !a0b1.getParent().isInstanceDescendant() ); TESTING_ASSERT( a0b1.getParent().getName() == "a0" ); TESTING_ASSERT( a0b1.getParent().getFullName() == "/a0" ); IObject b0a1( b0.getChild(0) ); TESTING_ASSERT( b0a1.isInstanceDescendant() ); TESTING_ASSERT( b0a1.getParent().isInstanceDescendant() ); IObject b0b1( b0.getChild(1) ); TESTING_ASSERT( b0b1.isInstanceDescendant() ); TESTING_ASSERT( b0b1.getName() == "b1" ); TESTING_ASSERT( b0b1.getFullName() == "/b0/b1" ); TESTING_ASSERT( b0b1.getParent().isInstanceDescendant() ); TESTING_ASSERT( b0b1.getParent().getName() == "b0" ); TESTING_ASSERT( b0b1.getParent().getFullName() == "/b0" ); IObject a0a1a2( a0a1.getChild(0) ); TESTING_ASSERT( !a0a1a2.isInstanceDescendant() ); TESTING_ASSERT( a0a1a2.getName() == "a2" ); TESTING_ASSERT( a0a1a2.getFullName() == "/a0/a1/a2" ); TESTING_ASSERT( !a0a1a2.getParent().isInstanceDescendant() ); TESTING_ASSERT( a0a1a2.getParent().getName() == "a1" ); TESTING_ASSERT( a0a1a2.getParent().getFullName() == "/a0/a1" ); TESTING_ASSERT( !a0a1a2.getParent().getParent().isInstanceDescendant() ); TESTING_ASSERT( a0a1a2.getParent().getParent().getName() == "a0" ); TESTING_ASSERT( a0a1a2.getParent().getParent().getFullName() == "/a0" ); IObject a0a1b2( a0a1.getChild(1) ); TESTING_ASSERT( a0a1b2.isInstanceDescendant() ); TESTING_ASSERT( a0a1b2.getName() == "b2" ); TESTING_ASSERT( a0a1b2.getFullName() == "/a0/a1/b2" ); TESTING_ASSERT( !a0a1b2.getParent().isInstanceDescendant() ); TESTING_ASSERT( a0a1b2.getParent().getName() == "a1" ); TESTING_ASSERT( a0a1b2.getParent().getFullName() == "/a0/a1" ); TESTING_ASSERT( !a0a1b2.getParent().getParent().isInstanceDescendant() ); TESTING_ASSERT( a0a1b2.getParent().getParent().getName() == "a0" ); TESTING_ASSERT( a0a1b2.getParent().getParent().getFullName() == "/a0" ); IObject a0b1a2( a0b1.getChild(0) ); TESTING_ASSERT( a0b1a2.isInstanceDescendant() ); TESTING_ASSERT( a0b1a2.getName() == "a2" ); TESTING_ASSERT( a0b1a2.getFullName() == "/a0/b1/a2" ); TESTING_ASSERT( a0b1a2.getParent().isInstanceDescendant() ); TESTING_ASSERT( a0b1a2.getParent().getName() == "b1" ); TESTING_ASSERT( a0b1a2.getParent().getFullName() == "/a0/b1" ); TESTING_ASSERT( !a0b1a2.getParent().getParent().isInstanceDescendant() ); TESTING_ASSERT( a0b1a2.getParent().getParent().getName() == "a0" ); TESTING_ASSERT( a0b1a2.getParent().getParent().getFullName() == "/a0" ); IObject a0b1b2( a0b1.getChild(1) ); TESTING_ASSERT( a0b1b2.isInstanceDescendant() ); TESTING_ASSERT( a0b1b2.getName() == "b2" ); TESTING_ASSERT( a0b1b2.getFullName() == "/a0/b1/b2" ); TESTING_ASSERT( a0b1b2.getParent().isInstanceDescendant() ); TESTING_ASSERT( a0b1b2.getParent().getName() == "b1" ); TESTING_ASSERT( a0b1b2.getParent().getFullName() == "/a0/b1" ); TESTING_ASSERT( !a0b1b2.getParent().getParent().isInstanceDescendant() ); TESTING_ASSERT( a0b1b2.getParent().getParent().getName() == "a0" ); TESTING_ASSERT( a0b1b2.getParent().getParent().getFullName() == "/a0" ); IObject b0a1a2( b0a1.getChild(0) ); TESTING_ASSERT( b0a1a2.isInstanceDescendant() ); TESTING_ASSERT( b0a1a2.getName() == "a2" ); TESTING_ASSERT( b0a1a2.getFullName() == "/b0/a1/a2" ); TESTING_ASSERT( b0a1a2.getParent().isInstanceDescendant() ); TESTING_ASSERT( b0a1a2.getParent().getName() == "a1" ); TESTING_ASSERT( b0a1a2.getParent().getFullName() == "/b0/a1" ); TESTING_ASSERT( b0a1a2.getParent().getParent().isInstanceDescendant() ); TESTING_ASSERT( b0a1a2.getParent().getParent().getName() == "b0" ); TESTING_ASSERT( b0a1a2.getParent().getParent().getFullName() == "/b0" ); IObject b0a1b2( b0a1.getChild(1) ); TESTING_ASSERT( b0a1b2.isInstanceDescendant() ); TESTING_ASSERT( b0a1b2.getName() == "b2" ); TESTING_ASSERT( b0a1b2.getFullName() == "/b0/a1/b2" ); TESTING_ASSERT( b0a1b2.getParent().isInstanceDescendant() ); TESTING_ASSERT( b0a1b2.getParent().getName() == "a1" ); TESTING_ASSERT( b0a1b2.getParent().getFullName() == "/b0/a1" ); TESTING_ASSERT( b0a1b2.getParent().getParent().isInstanceDescendant() ); TESTING_ASSERT( b0a1b2.getParent().getParent().getName() == "b0" ); TESTING_ASSERT( b0a1b2.getParent().getParent().getFullName() == "/b0" ); IObject b0b1a2( b0b1.getChild(0) ); TESTING_ASSERT( b0b1a2.isInstanceDescendant() ); TESTING_ASSERT( b0b1a2.getName() == "a2" ); TESTING_ASSERT( b0b1a2.getFullName() == "/b0/b1/a2" ); TESTING_ASSERT( b0b1a2.getParent().isInstanceDescendant() ); TESTING_ASSERT( b0b1a2.getParent().getName() == "b1" ); TESTING_ASSERT( b0b1a2.getParent().getFullName() == "/b0/b1" ); TESTING_ASSERT( b0b1a2.getParent().getParent().isInstanceDescendant() ); TESTING_ASSERT( b0b1a2.getParent().getParent().getName() == "b0" ); TESTING_ASSERT( b0b1a2.getParent().getParent().getFullName() == "/b0" ); IObject b0b1b2( b0b1.getChild(1) ); TESTING_ASSERT( b0b1b2.isInstanceDescendant() ); TESTING_ASSERT( b0b1b2.getName() == "b2" ); TESTING_ASSERT( b0b1b2.getFullName() == "/b0/b1/b2" ); TESTING_ASSERT( b0b1b2.getParent().isInstanceDescendant() ); TESTING_ASSERT( b0b1b2.getParent().getName() == "b1" ); TESTING_ASSERT( b0b1b2.getParent().getFullName() == "/b0/b1" ); TESTING_ASSERT( b0b1b2.getParent().getParent().isInstanceDescendant() ); TESTING_ASSERT( b0b1b2.getParent().getParent().getName() == "b0" ); TESTING_ASSERT( b0b1b2.getParent().getParent().getFullName() == "/b0" ); } } //-***************************************************************************** int main( int argc, char* argv[] ) { const std::string oarkhive( "instancetest_ogawa.abc" ); const std::string harkhive( "insatncetest_hdf5.abc" ); const std::string oarkhive2( "diabolical.instancet_ogawa.abc" ); const std::string harkhive2( "diabolical.instancet_hdf5.abc" ); bool useOgawa = true; simpleTestOut( oarkhive, useOgawa ); simpleTestIn( oarkhive ); diabolicalInstance( oarkhive2, useOgawa ); #ifdef ALEMBIC_WITH_HDF5 useOgawa = false; simpleTestOut( harkhive, useOgawa ); simpleTestIn( harkhive ); diabolicalInstance( harkhive2, useOgawa ); #endif return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/ObjectTests.cpp000066400000000000000000000324171507001531700217610ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif namespace Abc = Alembic::Abc; using namespace Abc; namespace AbcF = Alembic::AbcCoreFactory; // // The tests in this file are intended to exercize the Abc // API; specifically writing and reading of simple objects in // parent-child hierarchies. // void writeFlatHierarchy(const std::string &archiveName, bool useOgawa) { const int numChildren = 10; // Create an archive for writing. Indicate that we want Alembic to // throw exceptions on errors. OArchive archive; if (useOgawa) { archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); } #endif OObject archiveTop = archive.getTop(); for (int ii=0; ii #include #include #include #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif namespace Abc = Alembic::Abc; namespace AbcF = Alembic::AbcCoreFactory; using namespace Abc; //-***************************************************************************** static const V3f scalarV3fval( -1.0f, 32.0f, -90.0f ); static const chrono_t v3fStartTime = -4.3; static const chrono_t intStartTime = 2.9; static const chrono_t dt = 1.0 / 24.0; static const size_t numV3fPoints = 20; static const size_t numV3fSamps = 31; static const size_t numIntPoints = 11; static const size_t numIntSamps = 7; static const chrono_t CHRONO_EPSILON = \ std::numeric_limits::epsilon() * 32.0; //-***************************************************************************** void simpleTestOut( const std::string &iArchiveName, bool useOgawa ) { OArchive archive; if (useOgawa) { archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); } #endif OObject archiveTop( archive, kTop ); // 0th archive child OObject ac0( archiveTop, "ac0" ); // 0th archive child child OObject acc0( ac0, "acc0" ); // 1th archive child OObject ac1( archiveTop, "ac1" ); OInt32ArrayProperty ac1iap0( ac1.getProperties(), "iap0" ); // all property manipulation is through a hidden compound property named // ".prop" automatically by Alembic. // // All property access is through that. OCompoundProperty ac0Props = ac0.getProperties(); OCompoundProperty acc0Props = acc0.getProperties(); // Here we create a new Compound Property named "acc0CProp0" to hold // a couple Int Scalar Properties OCompoundProperty acc0CProp0( acc0Props, "acc0CProp0" ); OInt32Property acc0cp0ip0( acc0CProp0, "acc0cp0ip0" ); acc0cp0ip0.set( 0 ); OInt32Property acc0cp0ip1( acc0CProp0, "acc0cp0ip1" ); acc0cp0ip1.set( 1 ); // some scalar props OV3fProperty ac0V3fp0( ac0Props, "ac0V3fp0" ); const AbcA::PropertyHeader * ac0V3fp0Header = ac0Props.getPropertyHeader( "ac0V3fp0" ); TESTING_ASSERT( OV3fProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( IV3fProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! OFloatProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! IFloatProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! ON3fProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! IN3fProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! OV3dProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! IV3dProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! OV2fProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! IV2fProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! OV2dProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! IV2dProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! OInt32Property::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! IInt32Property::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! ODoubleProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! IDoubleProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! OV3fArrayProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! IV3fArrayProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! OFloatArrayProperty::matches( *ac0V3fp0Header ) ); TESTING_ASSERT( ! IFloatArrayProperty::matches( *ac0V3fp0Header ) ); ac0V3fp0.set( scalarV3fval ); ON3fProperty ac0N3fp0( ac0Props, "ac0N3fp0" ); const AbcA::PropertyHeader * ac0N3fp0Header = ac0Props.getPropertyHeader( "ac0N3fp0" ); TESTING_ASSERT( ON3fProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( IN3fProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! OFloatProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! OFloatProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! OV3fProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! ON3dProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! ON2fProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! ON2dProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! OInt32Property::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! ODoubleProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! ON3fArrayProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! OFloatArrayProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! IFloatProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! IFloatProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! IV3fProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! IN3dProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! IN2fProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! IN2dProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! IInt32Property::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! IDoubleProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! IN3fArrayProperty::matches( *ac0N3fp0Header ) ); TESTING_ASSERT( ! IFloatArrayProperty::matches( *ac0N3fp0Header ) ); ac0N3fp0.set( scalarV3fval ); OP3fProperty ac0P3fp0( ac0Props, "ac0P3fp0" ); const AbcA::PropertyHeader * ac0P3fp0Header = ac0Props.getPropertyHeader( "ac0P3fp0" ); TESTING_ASSERT( OP3fProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( IP3fProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! OFloatProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! OV3fProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! OP3dProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! OP2fProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! OP2dProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! OInt32Property::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! ODoubleProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! OP3fArrayProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! OFloatArrayProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! IFloatProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! IV3fProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! IP3dProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! IP2fProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! IP2dProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! IInt32Property::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! IDoubleProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! IP3fArrayProperty::matches( *ac0P3fp0Header ) ); TESTING_ASSERT( ! IFloatArrayProperty::matches( *ac0P3fp0Header ) ); ac0P3fp0.set( scalarV3fval ); OInt32Property acc0ip0( acc0Props, "acc0ip0" ); const AbcA::PropertyHeader * acc0ip0Header = acc0Props.getPropertyHeader( "acc0ip0" ); TESTING_ASSERT( OInt32Property::matches( *acc0ip0Header ) ); TESTING_ASSERT( IInt32Property::matches( *acc0ip0Header ) ); TESTING_ASSERT( ! OFloatProperty::matches( *acc0ip0Header ) ); TESTING_ASSERT( ! OInt32ArrayProperty::matches( *acc0ip0Header ) ); TESTING_ASSERT( ! IFloatProperty::matches( *acc0ip0Header ) ); TESTING_ASSERT( ! IInt32ArrayProperty::matches( *acc0ip0Header ) ); TESTING_ASSERT( ! IBox2iProperty::matches( *acc0ip0Header ) ); acc0ip0.set( 99 ); OBoolProperty acc0bp0( acc0Props, "acc0bp0" ); const AbcA::PropertyHeader * acc0bp0Header = acc0Props.getPropertyHeader( "acc0bp0" ); TESTING_ASSERT( OBoolProperty::matches( *acc0bp0Header ) ); TESTING_ASSERT( IBoolProperty::matches( *acc0bp0Header ) ); TESTING_ASSERT( ! OInt32Property::matches( *acc0bp0Header ) ); TESTING_ASSERT( ! IInt32Property::matches( *acc0bp0Header ) ); TESTING_ASSERT( ! OBoolArrayProperty::matches( *acc0bp0Header ) ); TESTING_ASSERT( ! IBoolArrayProperty::matches( *acc0bp0Header ) ); acc0bp0.set( false ); TimeSamplingPtr ts( new TimeSampling(1.0/24.0, v3fStartTime) ); // now some array props OV3fArrayProperty acc0V3fap0( acc0Props, "acc0V3fap0", ts ); const AbcA::PropertyHeader * acc0V3fap0Header = acc0Props.getPropertyHeader( "acc0V3fap0" ); TESTING_ASSERT( OV3fArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( IV3fArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( ! OFloatArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( ! IFloatArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( ! OInt32ArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( ! OP3fArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( ! OV3fProperty::matches( *acc0V3fap0Header ) ); OP3fArrayProperty acc0P3fap0( acc0Props, "acc0P3fap0", ts ); const AbcA::PropertyHeader * acc0P3fap0Header = acc0Props.getPropertyHeader( "acc0P3fap0" ); TESTING_ASSERT( OP3fArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( IP3fArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( ! OFloatArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( ! IFloatArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( ! OInt32ArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( ! OV3fArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( ! OP3fProperty::matches( *acc0P3fap0Header ) ); ON3fArrayProperty acc0N3fap0( acc0Props, "acc0N3fap0", ts ); ts.reset( new TimeSampling(1.0/24.0, intStartTime) ); OInt32ArrayProperty ac0iap0( ac0Props, "ac0iap0", ts ); // make some data for our array props std::vector v3fpoints( numV3fPoints ); std::vector intpoints( numIntPoints ); chrono_t t = v3fStartTime; for ( size_t i = 0 ; i < numV3fSamps ; ++i ) { for ( std::vector::iterator iter = v3fpoints.begin() ; iter != v3fpoints.end() ; ++iter ) { (*iter) = V3f( i + t, i + t, i + t ); } acc0V3fap0.set( v3fpoints ); acc0P3fap0.set( v3fpoints ); acc0N3fap0.set( v3fpoints ); t += dt; } t = intStartTime; for ( size_t i = 0 ; i < numIntSamps ; ++i ) { for ( size_t j = 0 ; j < numIntPoints ; ++j ) { intpoints[j] = j + i; } ac0iap0.set( intpoints ); t += dt; } // test that we did everything right TESTING_ASSERT( ac0.getNumChildren() == 1 ); TESTING_ASSERT( ac0Props.getNumProperties() == 4 ); TESTING_ASSERT( acc0.getNumChildren() == 0 ); TESTING_ASSERT( acc0Props.getNumProperties() == 6 ); } //-***************************************************************************** void simpleTestIn( const std::string &iArchiveName, bool useOgawa) { AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(iArchiveName, coreType); TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) || (!useOgawa && coreType == AbcF::IFactory::kHDF5) ); IObject archiveTop = archive.getTop(); IObject ac0( archiveTop, "ac0" ); IObject acc0( ac0, "acc0" ); IObject ac1( archiveTop, "ac1" ); IInt32ArrayProperty ac1iap0( ac1.getProperties(), "iap0" ); const AbcA::PropertyHeader * iap0Header = ac1.getProperties().getPropertyHeader( "iap0" ); TESTING_ASSERT( IInt32ArrayProperty::matches( *iap0Header ) ); TESTING_ASSERT( OInt32ArrayProperty::matches( *iap0Header ) ); TESTING_ASSERT( ! IFloatArrayProperty::matches( *iap0Header ) ); TESTING_ASSERT( ! IV3fArrayProperty::matches( *iap0Header ) ); ISampleSelector ac1iap0iss; AbcA::index_t sampIdx = ac1iap0iss.getIndex( ac1iap0.getTimeSampling(), ac1iap0.getNumSamples() ); std::cout << "sampIdx: " << sampIdx << std::endl; // an object contains a single compound property that contains all // sub-properties; all property access is through that. ICompoundProperty ac0Props = ac0.getProperties(); ICompoundProperty acc0Props = acc0.getProperties(); TESTING_ASSERT( ac0.getNumChildren() == 1 ); TESTING_ASSERT( ac0Props.getNumProperties() == 4 ); TESTING_ASSERT( acc0.getNumChildren() == 0 ); TESTING_ASSERT( acc0Props.getNumProperties() == 6 ); std::cout << "ac0 has " << ac0.getNumChildren() << " children and " << ac0Props.getNumProperties() << " properties." << std::endl; std::cout << "acc0 has " << acc0.getNumChildren() << " children and " << acc0Props.getNumProperties() << " properties." << std::endl; for ( size_t i = 0 ; i < acc0Props.getNumProperties() ; ++i ) { std::cout << "acc0.getPropertyHeader( " << i << " ).getName(): " << acc0Props.getPropertyHeader( i ).getName() << std::endl; } ICompoundProperty acc0CProp0( acc0Props, "acc0CProp0" ); IInt32Property acc0cp0ip0( acc0CProp0, "acc0cp0ip0" ); IInt32Property acc0cp0ip1( acc0CProp0, "acc0cp0ip1" ); int acc0cp0ip0val = acc0cp0ip0.getValue(); int acc0cp0ip1val = acc0cp0ip1.getValue(); TESTING_ASSERT( acc0cp0ip0val == 0 ); TESTING_ASSERT( acc0cp0ip1val == 1 ); std::cout << "acc0cp0ip0 is " << acc0cp0ip0val << std::endl; std::cout << "acc0cp0ip1 is " << acc0cp0ip1val << std::endl; IV3fProperty ac0V3fp0( ac0Props, "ac0V3fp0", kStrictMatching ); IN3fProperty ac0N3fp0( ac0Props, "ac0N3fp0", kStrictMatching ); IP3fProperty ac0P3fp0( ac0Props, "ac0P3fp0", kStrictMatching ); // we expect this to throw when doing strict matching TESTING_ASSERT_THROW ( IP3fProperty( ac0Props, "ac0N3fp0", kStrictMatching ), Alembic::Util::Exception ); IInt32Property acc0ip0( acc0Props, "acc0ip0" ); IBoolProperty acc0bp0( acc0Props, "acc0bp0" ); TESTING_ASSERT( ! acc0bp0.getValue() ); std::cout << "bool scalar property acc0bp0 is false! Huzzah!" << std::endl; TESTING_ASSERT( acc0ip0.getValue() == 99 ); TESTING_ASSERT( ac0V3fp0.getValue() == scalarV3fval ); TESTING_ASSERT( ac0N3fp0.getValue() == scalarV3fval ); TESTING_ASSERT( ac0P3fp0.getValue() == scalarV3fval ); std::cout << "acc0ip0 is " << acc0ip0.getValue() << std::endl; std::cout << "ac0V3fp0 is " << ac0V3fp0.getValue() << std::endl; IV3fArrayProperty acc0V3fap0( acc0Props, "acc0V3fap0", kStrictMatching ); const AbcA::PropertyHeader * acc0V3fap0Header = acc0Props.getPropertyHeader( "acc0V3fap0" ); TESTING_ASSERT( OV3fArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( IV3fArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( ! OFloatArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( ! IFloatArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( ! IInt32ArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( ! IP3fArrayProperty::matches( *acc0V3fap0Header ) ); TESTING_ASSERT( ! IV3fProperty::matches( *acc0V3fap0Header ) ); V3fArraySamplePtr acc0V3fap0SampPtr; IP3fArrayProperty acc0P3fap0( acc0Props, "acc0P3fap0", kStrictMatching ); const AbcA::PropertyHeader * acc0P3fap0Header = acc0Props.getPropertyHeader( "acc0P3fap0" ); TESTING_ASSERT( OP3fArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( IP3fArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( ! OFloatArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( ! IFloatArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( ! IInt32ArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( ! IV3fArrayProperty::matches( *acc0P3fap0Header ) ); TESTING_ASSERT( ! IP3fProperty::matches( *acc0P3fap0Header ) ); P3fArraySamplePtr acc0P3fap0SampPtr; IN3fArrayProperty acc0N3fap0( acc0Props, "acc0N3fap0", kStrictMatching ); const AbcA::PropertyHeader * acc0N3fap0Header = acc0Props.getPropertyHeader( "acc0N3fap0" ); TESTING_ASSERT( ON3fArrayProperty::matches( *acc0N3fap0Header ) ); TESTING_ASSERT( IN3fArrayProperty::matches( *acc0N3fap0Header ) ); TESTING_ASSERT( ! OFloatArrayProperty::matches( *acc0N3fap0Header ) ); TESTING_ASSERT( ! IFloatArrayProperty::matches( *acc0N3fap0Header ) ); TESTING_ASSERT( ! IInt32ArrayProperty::matches( *acc0N3fap0Header ) ); TESTING_ASSERT( ! IV3fArrayProperty::matches( *acc0N3fap0Header ) ); TESTING_ASSERT( ! IP3fProperty::matches( *acc0N3fap0Header ) ); N3fArraySamplePtr acc0N3fap0SampPtr; TESTING_ASSERT_THROW ( IP3fProperty( ac0Props, "acc0V3fap0", kStrictMatching ), Alembic::Util::Exception ); IInt32ArrayProperty ac0iap0( ac0Props, "ac0iap0" ); Int32ArraySamplePtr ac0iap0SampPtr; const size_t numReadV3fSamps = acc0V3fap0.getNumSamples(); const size_t numReadN3fSamps = acc0N3fap0.getNumSamples(); const size_t numReadP3fSamps = acc0P3fap0.getNumSamples(); const size_t numReadIntSamps = ac0iap0.getNumSamples(); TESTING_ASSERT( numReadIntSamps == numIntSamps ); TESTING_ASSERT( numReadV3fSamps == numV3fSamps ); TESTING_ASSERT( numReadN3fSamps == numV3fSamps ); TESTING_ASSERT( numReadP3fSamps == numV3fSamps ); std::cout << "acc0V3fap0 has " << numReadV3fSamps << " samples." << std::endl; std::cout << "ac0iap0 has " << numReadIntSamps << " samples." << std::endl; // first the V3f array property for ( size_t i = 0 ; i < numV3fSamps ; ++i ) { acc0V3fap0.get( acc0V3fap0SampPtr, i ); acc0N3fap0.get( acc0N3fap0SampPtr, i ); acc0P3fap0.get( acc0P3fap0SampPtr, i ); size_t numPoints = acc0V3fap0SampPtr->size(); chrono_t time = acc0V3fap0.getTimeSampling()->getSampleTime( i ); chrono_t compTime = v3fStartTime + ( i * dt ); TESTING_ASSERT( numPoints == numV3fPoints ); TESTING_ASSERT( numPoints == acc0N3fap0SampPtr->size() ); TESTING_ASSERT( numPoints == acc0P3fap0SampPtr->size() ); TESTING_ASSERT( Imath::equalWithAbsError( time, compTime, CHRONO_EPSILON ) ); float32_t elementVal = i + time; TESTING_ASSERT( (*acc0V3fap0SampPtr)[0][0] == elementVal ); TESTING_ASSERT( (*acc0N3fap0SampPtr)[0][0] == elementVal ); TESTING_ASSERT( (*acc0P3fap0SampPtr)[0][0] == elementVal ); std::cout << "acc0V3fap0 at sample " << i << " is at time " << time << " and has " << numPoints << " points " << " with the values:" << std::endl; for ( size_t j = 0 ; j < numPoints ; ++j ) { std::cout << (*acc0V3fap0SampPtr)[j] << ", "; } std::cout << std::endl << std::endl; } // now the int array property for ( size_t i = 0 ; i < numIntSamps ; ++i ) { ac0iap0.get( ac0iap0SampPtr, i ); size_t numPoints = ac0iap0SampPtr->size(); chrono_t time = ac0iap0.getTimeSampling()->getSampleTime( i ); chrono_t compTime = intStartTime + ( i * dt ); TESTING_ASSERT( Imath::equalWithAbsError( time, compTime, CHRONO_EPSILON ) ); TESTING_ASSERT( numPoints == numIntPoints ); std::cout << "ac0iap0 at sample " << i << " is at time " << time << " and has " << numPoints << " points" << " with the values:" << std::endl; for ( size_t j = 0 ; j < numPoints ; ++j ) { Alembic::Util::int32_t val = (*ac0iap0SampPtr)[j]; TESTING_ASSERT( val == ( Alembic::Util::int32_t ) ( i + j ) ); std::cout << val << ", "; } std::cout << std::endl << std::endl; } } //-***************************************************************************** int main( int argc, char *argv[] ) { const std::string arkive( "test2archive.abc" ); bool useOgawa = true; simpleTestOut( arkive, useOgawa ); simpleTestIn( arkive, useOgawa ); #ifdef ALEMBIC_WITH_HDF5 useOgawa = false; simpleTestOut( arkive, useOgawa ); simpleTestIn( arkive, useOgawa ); #endif return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/OctessenceBug16.cpp000066400000000000000000000300631507001531700224230ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include namespace Abc = Alembic::Abc; using namespace Abc; using Alembic::AbcCoreAbstract::chrono_t; using Alembic::AbcCoreAbstract::index_t; // // The tests in this file were originally intended to demonstrate // Alembic Issue 16 "memcpy error in Alembic::HDF5::Attribute::writeAll" // revealed by valgrind testing. We'll test this with Ogawa instead // void writeSimpleProperties(const std::string &archiveName) { const Alembic::Util::uint32_t numSamples = 5; const chrono_t dt = 1.0 / 24.0; TimeSamplingType tst( dt ); // uniform with cycle=dt std::vector < chrono_t > timeSamp(1, 666.0); TimeSampling ts(tst, timeSamp); // Create an archive for writing. Indicate that we want Alembic to // throw exceptions on errors. OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); Alembic::Util::uint32_t tsidx = archive.addTimeSampling(ts); OObject archiveTop = archive.getTop(); // Create a child, parented under the archive std::string name = "child"; OObject child( archiveTop, name ); OCompoundProperty childProps = child.getProperties(); // Create a scalar property on this child object named 'mass' ODoubleProperty mass( childProps, // owner "mass", // name tsidx ); // Write out the samples for (Alembic::Util::uint32_t tt=0; tt void printSampleValue( PROPERTY_CLASS& iProp, const ISampleSelector &iSS ) { std::cout << iProp.getValue( iSS ) << " "; } void readSimpleProperties(const std::string &archiveName) { // Open an existing archive for reading. Indicate that we want // Alembic to throw exceptions on errors. IArchive archive( Alembic::AbcCoreOgawa::ReadArchive(), archiveName, ErrorHandler::kThrowPolicy ); IObject archiveTop = archive.getTop(); // Determine the number of (top level) children the archive has const unsigned int numChildren = archiveTop.getNumChildren(); ABCA_ASSERT( numChildren == 1, "Wrong number of children (expected 1)"); std::cout << "The archive has " << numChildren << " children:" << std::endl; // Iterate through them, print out their names IObject child( archiveTop, archiveTop.getChildHeader( 0 ).getName() ); std::cout << " " << child.getName(); std::cout << " has " << child.getNumChildren() << " children" << std::endl; // Properties ICompoundProperty props = child.getProperties(); size_t numProperties = props.getNumProperties(); std::cout << " ..and " << numProperties << " simple properties" << std::endl; std::vector propNames; for (unsigned int pp=0; pp getScalarProperty( propNames[jj] )->getTimeSampling(); size_t numSamples = GetCompoundPropertyReaderPtr( props )-> getScalarProperty( propNames[jj] )->getNumSamples(); std::cout << " ..with time sampling: "; std::cout << " " << numSamples << " samples"; if (numSamples > 0) { std::cout << " ( "; for (unsigned int ss=0; ssgetSampleTime(ss) << " "; std::cout << ")"; } std::cout << std::endl; std::cout << " ..and values: "; if (numSamples > 0) { for (unsigned int ss=0; ss #include #include #include namespace Abc = Alembic::Abc; using namespace Abc; //-***************************************************************************** static const chrono_t g_doubleStartTime = 0.1; static const chrono_t g_dt = 1.0 / 24.0; static const size_t g_numDoubleSamps = 5; //-***************************************************************************** void scramble_heap() { const size_t BUFFSIZE = 8192 / 4; char *buf_ptrs[BUFFSIZE]; for ( size_t i = 0 ; i < BUFFSIZE ; i++ ) { size_t alloc_size = 4 * i + 1; buf_ptrs[i] = (char *)malloc( alloc_size ); memset( buf_ptrs[i], 0xff, alloc_size ); } for ( size_t i = 0 ; i < BUFFSIZE ; i++ ) { free( buf_ptrs[i] ); } } //-***************************************************************************** void simpleTestOut( const std::string &iArchiveName ) { OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), iArchiveName ); OObject archiveTop = archive.getTop(); std::vector < chrono_t > timeSamps(g_numDoubleSamps); TimeSamplingType utst( g_dt ); // uniform time sampling TimeSamplingPtr uts( new TimeSampling(g_dt, g_doubleStartTime) ); TimeSamplingType atst( TimeSamplingType::kAcyclic ); // acyclic chrono_t t = g_doubleStartTime; for ( size_t j = 0 ; j < g_numDoubleSamps ; j++ ) { timeSamps[j] = t; t += g_dt; } TimeSamplingPtr ats( new TimeSampling(atst, timeSamps) ); OObject c0( archiveTop, "c0" ); OCompoundProperty c0Props = c0.getProperties(); ODoubleProperty dp0( c0Props, "uniformdoubleprop", uts ); ODoubleProperty dp1( c0Props, "acyclicdoubleprop", ats ); t = g_doubleStartTime; for ( size_t j = 0 ; j < g_numDoubleSamps ; j++ ) { dp0.set( 1.0 + 0.1 * j ); dp1.set( 1.0 + 0.1 * j ); t += g_dt; } TimeSamplingType _utst = dp0.getTimeSampling()->getTimeSamplingType(); TESTING_ASSERT( _utst.isUniform() ); } //-***************************************************************************** void simpleTestIn( const std::string &iArchiveName ) { IArchive archive( Alembic::AbcCoreOgawa::ReadArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); IObject archiveTop = archive.getTop(); IObject c0( archiveTop, "c0" ); ICompoundProperty c0Props = c0.getProperties(); TimeSamplingPtr uts = c0Props.getPtr()-> getScalarProperty( "uniformdoubleprop" )->getTimeSampling(); TimeSamplingPtr ats = c0Props.getPtr()-> getScalarProperty( "acyclicdoubleprop" )->getTimeSampling(); //IDoubleProperty dp0( c0Props, "uniformdoubleprop" ); //IDoubleProperty dp1( c0Props, "acyclicdoubleprop" ); //size_t numReadDoubleSamps = dp0.getNumSamples(); //TESTING_ASSERT( numReadDoubleSamps == g_numDoubleSamps ); //TESTING_ASSERT( dp1.getNumSamples() == numReadDoubleSamps ); //scramble_heap(); //const TimeSamplingType &utst = uts.getTimeSamplingType(); const TimeSamplingType utst = c0Props.getPtr()->getScalarProperty( "uniformdoubleprop" )->getTimeSampling()->getTimeSamplingType(); TESTING_ASSERT(utst.isUniform()); for ( size_t j = 0 ; j < g_numDoubleSamps ; j++ ) { chrono_t utime = uts->getSampleTime( j ); chrono_t atime = ats->getSampleTime( j ); chrono_t reftime = g_doubleStartTime + ( j * g_dt ); std::cout << "reference time: " << reftime << std::endl; std::cout << "uniform sample time: " << utime << std::endl; std::cout << "acyclic sample time: " << atime << std::endl; chrono_t ABSERROR = 0.00001; TESTING_ASSERT( Imath::equalWithAbsError( utime, reftime, ABSERROR ) ); TESTING_ASSERT( Imath::equalWithAbsError( atime, reftime, ABSERROR ) ); TESTING_ASSERT( Imath::equalWithAbsError( atime, utime, ABSERROR ) ); } } //-***************************************************************************** int main( int argc, char *argv[] ) { const std::string arkive( "octessence17.abc" ); simpleTestOut( arkive ); simpleTestIn( arkive ); return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/ParentingTest.cpp000066400000000000000000000247541507001531700223240ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif #include #include namespace Abc = Alembic::Abc; using namespace Abc; namespace AbcF = Alembic::AbcCoreFactory; using Alembic::AbcCoreAbstract::chrono_t; using Alembic::AbcCoreAbstract::index_t; using Alembic::Util::uint32_t; using Alembic::Util::float32_t; static const V3f scalarV3fval( -1.0f, 32.0f, -90.0f ); static const chrono_t startTime = 5.7; static const chrono_t dt = 1.0 / 24.0; static const chrono_t CHRONO_EPSILON = \ std::numeric_limits::epsilon() * 32.0; //-***************************************************************************** void simpleTestOut( const std::string &iArchiveName, bool useOgawa ) { OArchive archive; if (useOgawa) { archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); } #endif // all child Objects in an Archive are actually children of the single // top Object in an Archive OObject topobj = archive.getTop(); // 0th archive child OObject ac0( topobj, "ac0" ); // 0th archive child child OObject acc0( ac0, "acc0" ); // all property manipulation is through an Object's single CompoundProperty OCompoundProperty ac0Props = ac0.getProperties(); OCompoundProperty acc0Props = acc0.getProperties(); // some scalar props OV3fProperty ac0V3fp0( ac0Props, "ac0V3fp0" ); ac0V3fp0.set( scalarV3fval ); TimeSampling ts(dt, startTime); Alembic::Util::uint32_t tsidx = archive.addTimeSampling(ts); // now some array props OV3fArrayProperty acc0V3fap0( acc0Props, "acc0V3fap0", tsidx ); chrono_t t = startTime; const size_t numPoints = 7; const size_t numSamps = 5; std::vector points( numPoints ); for ( size_t i = 0 ; i < numSamps ; ++i ) { for ( std::vector::iterator iter = points.begin() ; iter != points.end() ; ++iter ) { (*iter) = V3f( i + t, i + t, i + t ); } acc0V3fap0.set( points ); t += dt; } // OK, test some parentage { OObject _foo; OObject _parent = acc0; while ( _parent ) { std::cout << "_parent.getFullName(): " << _parent.getFullName() << std::endl; _foo = _parent.getParent(); _parent = _foo; } } { OCompoundProperty _foo; OCompoundProperty _parent = acc0Props; while ( _parent ) { std::cout << "_parent.getName(): " << _parent.getName() << std::endl; _foo = _parent.getParent(); _parent = _foo; } } // if the program exits, it means parenting works. } //-***************************************************************************** void simpleTestIn( const std::string &iArchiveName ) { AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(iArchiveName, coreType); // an archive has a single top object which contains all its children IObject topObject = archive.getTop(); IObject ac0( topObject, "ac0" ); IObject acc0( ac0, "acc0" ); // an object contains a single compound property that contains all // sub-properties; all property access is through that. ICompoundProperty ac0Props = ac0.getProperties(); ICompoundProperty acc0Props = acc0.getProperties(); IV3fProperty ac0V3fp0( ac0Props, "ac0V3fp0" ); IV3fArrayProperty acc0V3fap0( acc0Props, "acc0V3fap0" ); V3fArraySamplePtr acc0V3fap0SampPtr; const size_t numSamps = acc0V3fap0.getNumSamples(); std::cout << "acc0V3fap0 has " << numSamps << " samples." << std::endl; for ( size_t i = 0 ; i < numSamps ; ++i ) { acc0V3fap0.get( acc0V3fap0SampPtr, i ); size_t numPoints = acc0V3fap0SampPtr->size(); chrono_t time = acc0V3fap0.getTimeSampling()->getSampleTime( i ); chrono_t compTime = startTime + ( i * dt ); std::cout << "acc0fap0 at sample " << i << " is at time " << time << " and has " << numPoints << " points " << " with the values:" << std::endl; float32_t elementVal = i + time; TESTING_ASSERT( (*acc0V3fap0SampPtr)[0][0] == elementVal ); TESTING_ASSERT( Imath::equalWithAbsError( time, compTime, CHRONO_EPSILON ) ); for ( size_t j = 0 ; j < numPoints ; ++j ) { std::cout << (*acc0V3fap0SampPtr)[j] << ", "; } std::cout << std::endl << std::endl; } // OK, test some parentage { IObject _foo; IObject _parent = acc0; while ( _parent ) { std::cout << "_parent.getFullName(): " << _parent.getFullName() << std::endl; _foo = _parent.getParent(); _parent = _foo; } } { ICompoundProperty _foo; ICompoundProperty _parent = acc0Props; while ( _parent ) { std::cout << "_parent.getName(): " << _parent.getName() << std::endl; _foo = _parent.getParent(); _parent = _foo; } } // if the program exits, it means parenting works } void scopingTest(bool useOgawa) { { ODoubleProperty propScalar; ODoubleArrayProperty propArray; { OArchive archive; if (useOgawa) { archive = CreateArchiveWithInfo( Alembic::AbcCoreOgawa::WriteArchive(), "propScopeTest.abc", "Alembic test", "", MetaData() ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = CreateArchiveWithInfo( Alembic::AbcCoreHDF5::WriteArchive(), "propScopeTest.abc", "Alembic test", "", MetaData() ); } #endif OObject childA( archive.getTop(), "a" ); propScalar = ODoubleProperty(childA.getProperties(), "scalar", 0); propArray = ODoubleArrayProperty(childA.getProperties(), "array", 0); } std::vector< double > values(3, 2.0); propArray.set( values ); propScalar.set( 4.0 ); propScalar.set( 5.0 ); TESTING_ASSERT( propArray.getParent().getObject().getArchive().getName() == "propScopeTest.abc"); TESTING_ASSERT( propScalar.getParent().getObject().getArchive().getName() == "propScopeTest.abc"); } { IDoubleProperty propScalar; IDoubleArrayProperty propArray; { AbcF::IFactory factory; AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive("propScopeTest.abc", coreType); IObject top(archive.getTop(), "a"); propScalar = IDoubleProperty(top.getProperties(), "scalar"); propArray = IDoubleArrayProperty(top.getProperties(), "array"); } TESTING_ASSERT( propArray.getParent().getObject().getArchive().getName() == "propScopeTest.abc"); TESTING_ASSERT( propScalar.getParent().getObject().getArchive().getName() == "propScopeTest.abc"); DoubleArraySamplePtr samp; size_t sampNum = 0; propArray.get(samp, sampNum); TESTING_ASSERT( samp->size() == 3 ); TESTING_ASSERT( (*samp)[0] == 2.0 && (*samp)[1] == 2.0 && (*samp)[2] == 2.0 ); double scalarVal = 0.0; propScalar.get( scalarVal, sampNum ); TESTING_ASSERT( scalarVal == 4.0 ); sampNum ++; propScalar.get( scalarVal, sampNum ); TESTING_ASSERT( scalarVal == 5.0 ); } } //-***************************************************************************** int main( int argc, char *argv[] ) { const std::string arkive( "parentstest.abc" ); bool useOgawa = true; simpleTestOut( arkive, useOgawa ); simpleTestIn( arkive ); scopingTest(useOgawa); #ifdef ALEMBIC_WITH_HDF5 useOgawa = false; simpleTestOut( arkive, useOgawa ); simpleTestIn( arkive ); scopingTest(useOgawa); #endif return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/PropertyTests.cpp000066400000000000000000000451731507001531700224020ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif namespace AbcF = Alembic::AbcCoreFactory; namespace Abc = Alembic::Abc; using namespace Abc; using Alembic::AbcCoreAbstract::chrono_t; using Alembic::AbcCoreAbstract::index_t; using Alembic::Util::uint32_t; // // The tests in this file are intended to exercize the Abc API; // specifically writing and reading of propertues in parent-child // hierarchies // void writeSimpleProperties(const std::string &archiveName, bool useOgawa) { const int numChildren = 3; const int numSamples = 5; const chrono_t dt = 1.0 / 24.0; TimeSampling ts(dt, 666.0); // uniform with cycle=dt starting at 666.0 // Create an archive for writing. Indicate that we want Alembic to // throw exceptions on errors. OArchive archive; if (useOgawa) { archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); } #endif OObject archiveTop = archive.getTop(); Alembic::Util::uint32_t tsidx = archive.addTimeSampling(ts); OObject foochild( archiveTop, "foochild" ); Alembic::AbcCoreAbstract::MetaData md; SetSourceName(md, "potato"); ODoubleProperty foodub( foochild.getProperties(), "foodub", 0, md); for ( size_t i = 0 ; i < 10 ; i++ ) { foodub.set( 2.0 ); } for (int ii=0; ii void printSampleValue( PROPERTY_CLASS& iProp, const ISampleSelector &iSS ) { std::cout << iProp.getValue( iSS ) << " "; } void readSimpleProperties(const std::string &archiveName) { // Open an existing archive for reading. Indicate that we want // Alembic to throw exceptions on errors. AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(archiveName, coreType); IObject archiveTop = archive.getTop(); // Determine the number of (top level) children the archive has const int numChildren = archiveTop.getNumChildren(); TESTING_ASSERT( numChildren == 4 ); std::cout << "The archive has " << numChildren << " children:" << std::endl; // Iterate through them, print out their names for (int ii=0; ii propNames; for (int pp=0; pp getScalarProperty( propNames[jj] )->getTimeSampling(); int numSamples = ts->getNumStoredTimes(); std::cout << " ..and " << ts->getTimeSamplingType() << std::endl << " ..and " << numSamples << " samples at times: "; if (numSamples > 0) { std::cout << " ( "; for (int ss=0; ssgetSampleTime(ss) << " "; std::cout << ")"; } std::cout << std::endl; std::cout << " ..and values: "; if (numSamples > 0) { for (int ss=0; ss propNames; for (int pp=0; pp #include #include #include #include #ifdef ALEMBIC_WITH_HDF5 #include #endif namespace Abc = Alembic::Abc; using namespace Abc; namespace AbcF = Alembic::AbcCoreFactory; //-***************************************************************************** static std::vector intArraySamp; static std::set PATHS; static const Alembic::Util::int32_t NUM_TOP_CHILDREN = 100; static const Alembic::Util::int32_t DEPTH = 210; static const Alembic::Util::int32_t HIGHVAL = 200; typedef std::pair< std::set::iterator, bool > PATH_PAIR; //-***************************************************************************** void makeIntArraySamp() { for ( Alembic::Util::int32_t i = 0 ; i < HIGHVAL ; i++ ) { intArraySamp.push_back( i ); } } //-***************************************************************************** void makeDeepHierarchy( OObject parent, const int level ) { if ( level > DEPTH ) { OCompoundProperty p = parent.getProperties(); OInt32ArrayProperty iap( p, "intArrayProp", 0 ); iap.set( intArraySamp ); return; } std::ostringstream strm; strm << level; std::string levelName = strm.str(); makeDeepHierarchy( OObject( parent, levelName ), level + 1 ); } //-***************************************************************************** void readDeepHierarchy( IObject parent, const int level, const IObject& orig ) { if ( level > DEPTH ) { ICompoundProperty p = parent.getProperties(); IInt32ArrayProperty iap( p, "intArrayProp" ); std::string fullName = const_cast( iap.getObject().getFullName() ); PATH_PAIR ret = PATHS.insert( fullName ); Int32ArraySamplePtr sampPtr = iap.getValue(); TESTING_ASSERT( sampPtr->get()[5] == 5 ); TESTING_ASSERT( sampPtr->get()[99] == 99 ); TESTING_ASSERT( sampPtr->size() == ( size_t ) HIGHVAL ); TESTING_ASSERT( ret.second ); TESTING_ASSERT( fullName == parent.getFullName() ); // walk back up the tree until you find the first child object // under the top object, and check that it's the one we started // with. IObject _p = parent; while ( _p.getParent().getParent() ) { _p = _p.getParent(); } TESTING_ASSERT( _p.getFullName() == orig.getFullName() ); return; } std::ostringstream strm; strm << level; std::string levelName = strm.str(); readDeepHierarchy( IObject( parent, levelName ), level + 1, orig ); } //-***************************************************************************** void simpleTestOut( const std::string &iArchiveName, bool useOgawa ) { OArchive archive; if (useOgawa) { archive = OArchive( Alembic::AbcCoreOgawa::WriteArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); } #ifdef ALEMBIC_WITH_HDF5 else { archive = OArchive( Alembic::AbcCoreHDF5::WriteArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); } #endif OObject archiveTop( archive, kTop ); // create 100 top-level children for ( int i = 0 ; i < NUM_TOP_CHILDREN ; i++ ) { std::ostringstream strm; strm << i; std::string name = strm.str(); OObject obj( archiveTop, name ); makeDeepHierarchy( obj, 0 ); } } //-***************************************************************************** void simpleTestIn( const std::string &iArchiveName ) { AbcF::IFactory factory; factory.setPolicy( ErrorHandler::kThrowPolicy ); AbcF::IFactory::CoreType coreType; IArchive archive = factory.getArchive(iArchiveName, coreType); IObject archiveTop = archive.getTop(); TESTING_ASSERT( archiveTop.getNumChildren() == ( size_t )NUM_TOP_CHILDREN ); for ( int i = 0 ; i < NUM_TOP_CHILDREN ; i++ ) { std::ostringstream strm; strm << i; std::string cname = strm.str(); IObject obj( archiveTop, cname ); readDeepHierarchy( obj, 0, obj ); } TESTING_ASSERT( PATHS.size() == ( size_t ) NUM_TOP_CHILDREN ); } //-***************************************************************************** int main( int argc, char *argv[] ) { const std::string arkive( "redundantDataTest.abc" ); // make the int array sample values makeIntArraySamp(); bool useOgawa = true; simpleTestOut( arkive, useOgawa ); simpleTestIn( arkive ); PATHS.clear(); #ifdef ALEMBIC_WITH_HDF5 useOgawa = false; simpleTestOut( arkive, useOgawa ); simpleTestIn( arkive ); #endif return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/TypedArraySampleTest.cpp000066400000000000000000000070071507001531700236130ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #include namespace Abc = Alembic::Abc; using namespace Abc; //-***************************************************************************** void simpleTestOut( const std::string &iArchiveName ) { OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), iArchiveName ); OObject archiveTop( archive, kTop ); OObject c0( archiveTop, "c0" ); OCompoundProperty c0Props = c0.getProperties(); OInt32ArrayProperty i32ap( c0Props, "i32ap" ); Alembic::Util::shared_ptr > vptr( new std::vector( 50, 4 ) ); Int32ArraySample samp( *vptr ); i32ap.set( samp ); } //-***************************************************************************** void simpleTestIn( const std::string &iArchiveName ) { IArchive archive( Alembic::AbcCoreOgawa::ReadArchive(), iArchiveName, ErrorHandler::kThrowPolicy ); IObject archiveTop = archive.getTop(); IObject c0( archiveTop, "c0" ); ICompoundProperty c0Props = c0.getProperties(); IInt32ArrayProperty i32ap( c0Props, "i32ap" ); Int32ArraySamplePtr sptr = i32ap.getValue(); for ( int32_t i = 0 ; i < 50 ; ++i ) { TESTING_ASSERT( 4 == (*sptr)[i] ); //std::cout << (*sptr)[i] << std::endl; } } //-***************************************************************************** int main( int argc, char *argv[] ) { const std::string arkive( "typedArraySample.abc" ); simpleTestOut( arkive ); simpleTestIn( arkive ); return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/UniformPropertyTest.cpp000066400000000000000000000147271507001531700235600ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include namespace Abc = Alembic::Abc; using namespace Abc; // // The tests in this file are intended to exercize the Abc API; // specifically writing and reading of uniformly samples properties // void writeProperty(const std::string &archiveName) { const int numSamples = 5; const chrono_t startTime = 123.0; const chrono_t dt = 1.0 / 24.0; // Create an archive for writing. Indicate that we want Alembic to // throw exceptions on errors. OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), archiveName, ErrorHandler::kThrowPolicy ); OObject archiveTop = archive.getTop(); // Create a child, parented under the archive std::string name = "child"; OObject child( archiveTop, name ); OCompoundProperty childProps = child.getProperties(); TimeSamplingPtr ts ( new TimeSampling( dt, startTime ) ); // Create a scalar property on this child object named 'mass' // with metadata that indicates it's expressed in kilograms MetaData units; units.set( "units", "kilogram" ); ODoubleProperty mass( childProps, // owner "mass", // name units, ts ); // uniform with cycle=dt for (int tt=0; tt void printSampleValue( PROPERTY_CLASS& iProp, const ISampleSelector &iSS ) { std::cout << iProp.getValue( iSS ) << " "; } void readProperty(const std::string &archiveName) { // Open an existing archive for reading. Indicate that we want // Alembic to throw exceptions on errors. std::cout << "Reading " << archiveName << std::endl; IArchive archive( Alembic::AbcCoreOgawa::ReadArchive(), archiveName, ErrorHandler::kThrowPolicy ); IObject archiveTop = archive.getTop(); // Determine the number of (top level) children the archive has const unsigned int numChildren = archiveTop.getNumChildren(); ABCA_ASSERT( numChildren == 1, "Wrong number of children (expected 1)"); std::cout << "The archive has " << numChildren << " children:" << std::endl; // Iterate through them, print out their names IObject child( archiveTop, archiveTop.getChildHeader(0).getName() ); std::cout << " " << child.getName(); // Properties ICompoundProperty props = child.getProperties(); size_t numProperties = props.getNumProperties(); // only top-level props ABCA_ASSERT( numProperties == 1, "Expected 1 property, found " << numProperties); std::cout << " with one property"; std::vector propNames(1); propNames[0] = props.getPropertyHeader(0).getName(); std::cout << " named " << propNames[0] << std::endl; PropertyType pType = props.getPropertyHeader(0).getPropertyType(); ABCA_ASSERT( pType == kScalarProperty, "Expected a scalar property, but didn't find one" ); std::cout << " which is a scalar property"; DataType dType = props.getPropertyHeader(0).getDataType(); ABCA_ASSERT( dType.getPod() == kFloat64POD, "Expected a double (kFloat64POD) property, but didn't" " find one" ); // We know this is a scalar property (I'm eliding the if/else // statements required to recognize this) IDoubleProperty mass( props, propNames[0] ); int numSamples = mass.getNumSamples(); std::cout << ".. it has " << numSamples << " samples" << std::endl; ABCA_ASSERT( numSamples == 5, "Expected 5 samples, found " << numSamples ); TimeSamplingPtr ts = mass.getTimeSampling(); std::cout << "..with time/value pairs: "; for (int ss=0; ssgetSampleTime( (index_t) ss ) << "/"; printSampleValue( mass, iss ); std::cout << " "; } std::cout << std::endl; // Done - the archive closes itself } int main( int argc, char *argv[] ) { // Write and read a simple archive: ten children, each with one // simple property try { std::string archiveName("uniform_sampling_test.abc"); writeProperty ( archiveName ); readProperty ( archiveName ); } catch (char * str ) { std::cout << "Exception raised: " << str; std::cout << " during uniform sampling test" << std::endl; return 1; } return 0; } alembic-1.8.9/lib/Alembic/Abc/Tests/fuzzer_issue26643.abc000066400000000000000000000004071507001531700226270ustar00rootroot00000000000000Ogawaÿ‚@   ÿ € ÿÿÿ€9€L €ÿ€ÿ€ alembic-1.8.9/lib/Alembic/Abc/Tests/test1.cpp000066400000000000000000000232061507001531700205640ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include namespace Abc = Alembic::Abc; using namespace Abc; using Alembic::AbcCoreAbstract::chrono_t; using Alembic::AbcCoreAbstract::index_t; using Alembic::Util::uint32_t; using Alembic::Util::float32_t; //-***************************************************************************** void simpleTestOut() { OArchive archive( Alembic::AbcCoreOgawa::WriteArchive(), "slappyJim.abc", ErrorHandler::kThrowPolicy ); OObject slim( OObject( archive, kTop ), "slim" ); OObject jubby( slim, "jubby" ); OObject mespa( jubby, "mespa" ); OCompoundProperty clampto( OCompoundProperty( mespa, kTop ), "clampto" ); OV3fProperty clanker( clampto, "clanker", 0 ); OInt32Property clunker( clampto, "clunker", 0 ); // By scoping it, it deletes itself immediately. OBoolProperty( OCompoundProperty( slim, kTop ), "slumber" ).set( false ); // Make a strangely sampled V3dArray { OObject spaniard( jubby, "spaniard" ); chrono_t sampTime = 0.0; std::vector points( ( size_t )71 ); // create our random samples std::vector < chrono_t > timeSamps(37); for ( index_t idx = 0; idx < 37; ++idx ) { timeSamps[idx] = sampTime; sampTime += 1.0 / ( idx + 1 ); } TimeSampling ts(TimeSamplingType( TimeSamplingType::kAcyclic ), timeSamps); Alembic::Util::uint32_t tsidx = archive.addTimeSampling(ts); OV3dArrayProperty pointy( OCompoundProperty( spaniard, kTop ), "pointy", tsidx); for ( index_t idx = 0; idx < 36; ++idx ) { if ( idx == 0 ) { for ( std::vector::iterator piter = points.begin(); piter != points.end(); ++piter ) { (*piter) = V3d( idx, idx, idx ); } } pointy.set( points ); } // Test that zero-sized samples work. points.resize( 0 ); pointy.set( points ); } //-************************************************************************* // STRING PROPERTIES //-************************************************************************* OObject oscar( mespa, "oscar" ); OStringProperty wildeName( OCompoundProperty( oscar, kTop ), "wildeName" ); wildeName.set( "Oscar" ); wildeName.set( "Wilde" ); // This is Lewis Carroll, not Oscar Wilde, but whatever. OStringArrayProperty jabber( OCompoundProperty( oscar, kTop ), "jabberwocky" ); { std::vector stanza1; stanza1.push_back( "twas" ); stanza1.push_back( "brillig" ); stanza1.push_back( "and" ); stanza1.push_back( "the" ); stanza1.push_back( "slithy" ); stanza1.push_back( "toves" ); jabber.set( stanza1 ); } { std::vector stanza2; stanza2.push_back( "did" ); stanza2.push_back( "gyre" ); stanza2.push_back( "and" ); stanza2.push_back( "gimble" ); stanza2.push_back( "in" ); stanza2.push_back( "the" ); stanza2.push_back( "wobe" ); jabber.set( stanza2 ); } { std::vector emptyStanza; jabber.set( emptyStanza ); } OFloatProperty radius( clampto, "radius" ); radius.set( 217.0f ); for ( index_t idx = 0; idx < 1; ++idx ) { V3f v( ( float )idx ); clanker.set( v ); clunker.set( ( Alembic::Util::int32_t )( 731 - ( int )idx ) ); } std::cout << "Gonna try to close: " << archive.getName() << std::endl; } //-***************************************************************************** void simpleTestIn() { IArchive archive( Alembic::AbcCoreOgawa::ReadArchive(), "slappyJim.abc", ErrorHandler::kThrowPolicy ); IObject slim( IObject( archive, kTop ), "slim" ); IObject jubby( slim, "jubby" ); IObject mespa( jubby, "mespa" ); ICompoundProperty clampto( ICompoundProperty( mespa, kTop ), "clampto" ); IV3fProperty clanker( clampto, "clanker" ); IInt32Property clunker( clampto, "clunker" ); // By scoping it, it deletes itself immediately. std::cout << "Do I Slumber? " << IBoolProperty( ICompoundProperty( slim, kTop ), "slumber" ).getValue() << std::endl; // Strangely sampled. { IObject spaniard( jubby, "spaniard" ); IV3dArrayProperty pointy( ICompoundProperty( spaniard, kTop ), "pointy" ); std::cout << "Num pointy spaniard samples: " << pointy.getNumSamples() << std::endl; size_t pointySampleIdx = pointy.getNumSamples() / 2; V3dArraySamplePtr pointySamp; pointy.get( pointySamp, pointySampleIdx ); ABCA_ASSERT( pointySamp, "should be valid" ); size_t numPoints = pointySamp->size(); std::cout << "Num points in sample: " << numPoints << std::endl; for ( size_t i = 0; i < numPoints; ++i ) { std::cout << "pointy[" << i << "] = " << (*pointySamp)[i] << std::endl; } // Test that we can get a zero-sized sample. std::cout << "Testing getting a zero-length sample" << std::endl; pointy.get( pointySamp, pointy.getNumSamples()-1 ); std::cout << "Zero length sample num points: " << pointySamp->size() << std::endl; } //-************************************************************************* // STRING PROPERTIES //-************************************************************************* IObject oscar( mespa, "oscar" ); IStringProperty wildeName( ICompoundProperty( oscar, kTop ), "wildeName" ); std::cout << "Oscar Wilde Names: " << std::endl; size_t numNames = wildeName.getNumSamples(); for ( size_t i = 0; i < numNames; ++i ) { std::cout << "\t" << i << ": " << wildeName.getValue( i ) << std::endl; } IStringArrayProperty jabber( ICompoundProperty( oscar, kTop ), "jabberwocky" ); std::cout << "Jabberwocky first two lines: " << std::endl; size_t numLines = jabber.getNumSamples(); std::cout << "Num lines: " << numLines << std::endl; for ( size_t i = 0; i < numLines; ++i ) { StringArraySamplePtr line = jabber.getValue( i ); if ( line ) { size_t numWords = line->size(); if ( numWords ) { std::cout << "\t"; for ( size_t j = 0; j < numWords; ++j ) { std::cout << " " << (*line)[j]; } std::cout << std::endl; } else { std::cout << "\tNo words in this line." << std::endl; } } } IFloatProperty radius( clampto, "radius" ); std::cout << "Num clanker samples: " << clanker.getNumSamples() << std::endl; std::cout << "Gonna try to close: " << archive.getName() << std::endl; } int main( int argc, char *argv[] ) { ABCA_ASSERT( sizeof( char ) == sizeof( Alembic::Util::int8_t ), "Alembic::Util::int8_t isn't 1 byte" ); ABCA_ASSERT( ( sizeof( wchar_t ) == sizeof( Alembic::Util::int8_t ) ) || ( sizeof( wchar_t ) == sizeof( Alembic::Util::int16_t ) ) || ( sizeof( wchar_t ) == sizeof( Alembic::Util::int32_t ) ), "wchar_t is an unexpedted size." ); simpleTestOut(); simpleTestIn(); Argument defArg; ABCA_ASSERT(GetTimeSamplingIndex(defArg) == 0, "index should be 1"); return 0; } alembic-1.8.9/lib/Alembic/Abc/TypedArraySample.h000066400000000000000000000317311507001531700213170ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_TypedArraySample_h #define Alembic_Abc_TypedArraySample_h #include #include namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { using Alembic::Util::Dimensions; //-***************************************************************************** template class TypedArraySample : public AbcA::ArraySample { public: typedef TRAITS traits_type; typedef TypedArraySample this_type; typedef typename TRAITS::value_type value_type; typedef typename std::vector value_vector; //-************************************************************************* // Default TypedArraySample() : AbcA::ArraySample( NULL, TRAITS::dataType(), Dimensions() ) {} //-************************************************************************* // From pointer+num or pointer+dims TypedArraySample( const value_type *iValues, size_t iNumVals ) : AbcA::ArraySample( reinterpret_cast( iValues ), TRAITS::dataType(), Dimensions( iNumVals ) ) {} TypedArraySample( const value_type *iValues, const Dimensions &iDims ) : AbcA::ArraySample( reinterpret_cast( iValues ), TRAITS::dataType(), iDims ) {} //-************************************************************************* // From std::vector TypedArraySample( const value_vector &iVec ) : AbcA::ArraySample( reinterpret_cast( iVec.size() > 0 ? &iVec.front() : NULL ), TRAITS::dataType(), Dimensions( iVec.size() ) ) {} // This is for the case in which the data is multi-dimensional TypedArraySample( const value_vector &iVec, const Dimensions &iDims ) : AbcA::ArraySample( reinterpret_cast( iVec.size() > 0 ? &iVec.front() : NULL ), TRAITS::dataType(), iDims ) { ABCA_ASSERT( iDims.numPoints() == iVec.size(), "Invalid dimensions in TypedArraySample" ); } //-************************************************************************* // COPY & ASSIGMENT //-************************************************************************* // From base copy TypedArraySample( const AbcA::ArraySample &iCopy ) : AbcA::ArraySample( iCopy ) { ABCA_ASSERT( iCopy.getDataType() == TRAITS::dataType(), "Invalid DataType in TypedArraySample. Expected: " << TRAITS::dataType() << ", but got: " << iCopy.getDataType() ); } TypedArraySample operator=( const AbcA::ArraySample &iCopy ) { ArraySample::operator=( iCopy ); ABCA_ASSERT( iCopy.getDataType() == TRAITS::dataType(), "Invalid DataType in TypedArraySample. Expected: " << TRAITS::dataType() << ", but got: " << iCopy.getDataType() ); return *this; } const value_type *get() const { return reinterpret_cast( getData() ); } const value_type *operator->() const { return this->get(); } //-************************************************************************* const value_type &operator[]( const size_t i ) const { return this->get()[i]; } //-************************************************************************* size_t size() const { return this->getDimensions().numPoints(); } static TypedArraySample emptySample() { return TypedArraySample( NULL, 0 ); } //-************************************************************************* ALEMBIC_OPERATOR_BOOL( ArraySample::valid() ); }; //-***************************************************************************** // TYPEDEFS //-***************************************************************************** typedef TypedArraySample BoolArraySample; typedef TypedArraySample UcharArraySample; typedef TypedArraySample CharArraySample; typedef TypedArraySample UInt16ArraySample; typedef TypedArraySample Int16ArraySample; typedef TypedArraySample UInt32ArraySample; typedef TypedArraySample Int32ArraySample; typedef TypedArraySample UInt64ArraySample; typedef TypedArraySample Int64ArraySample; typedef TypedArraySample HalfArraySample; typedef TypedArraySample FloatArraySample; typedef TypedArraySample DoubleArraySample; typedef TypedArraySample StringArraySample; typedef TypedArraySample WstringArraySample; typedef TypedArraySample V2sArraySample; typedef TypedArraySample V2iArraySample; typedef TypedArraySample V2fArraySample; typedef TypedArraySample V2dArraySample; typedef TypedArraySample V3sArraySample; typedef TypedArraySample V3iArraySample; typedef TypedArraySample V3fArraySample; typedef TypedArraySample V3dArraySample; typedef TypedArraySample P2sArraySample; typedef TypedArraySample P2iArraySample; typedef TypedArraySample P2fArraySample; typedef TypedArraySample P2dArraySample; typedef TypedArraySample P3sArraySample; typedef TypedArraySample P3iArraySample; typedef TypedArraySample P3fArraySample; typedef TypedArraySample P3dArraySample; typedef TypedArraySample Box2sArraySample; typedef TypedArraySample Box2iArraySample; typedef TypedArraySample Box2fArraySample; typedef TypedArraySample Box2dArraySample; typedef TypedArraySample Box3sArraySample; typedef TypedArraySample Box3iArraySample; typedef TypedArraySample Box3fArraySample; typedef TypedArraySample Box3dArraySample; typedef TypedArraySample M33fArraySample; typedef TypedArraySample M33dArraySample; typedef TypedArraySample M44fArraySample; typedef TypedArraySample M44dArraySample; typedef TypedArraySample QuatfArraySample; typedef TypedArraySample QuatdArraySample; typedef TypedArraySample C3hArraySample; typedef TypedArraySample C3fArraySample; typedef TypedArraySample C3cArraySample; typedef TypedArraySample C4hArraySample; typedef TypedArraySample C4fArraySample; typedef TypedArraySample C4cArraySample; typedef TypedArraySample N2fArraySample; typedef TypedArraySample N2dArraySample; typedef TypedArraySample N3fArraySample; typedef TypedArraySample N3dArraySample; //-***************************************************************************** typedef Alembic::Util::shared_ptr BoolArraySamplePtr; typedef Alembic::Util::shared_ptr UcharArraySamplePtr; typedef Alembic::Util::shared_ptr CharArraySamplePtr; typedef Alembic::Util::shared_ptr UInt16ArraySamplePtr; typedef Alembic::Util::shared_ptr Int16ArraySamplePtr; typedef Alembic::Util::shared_ptr UInt32ArraySamplePtr; typedef Alembic::Util::shared_ptr Int32ArraySamplePtr; typedef Alembic::Util::shared_ptr UInt64ArraySamplePtr; typedef Alembic::Util::shared_ptr Int64ArraySamplePtr; typedef Alembic::Util::shared_ptr HalfArraySamplePtr; typedef Alembic::Util::shared_ptr FloatArraySamplePtr; typedef Alembic::Util::shared_ptr DoubleArraySamplePtr; typedef Alembic::Util::shared_ptr StringArraySamplePtr; typedef Alembic::Util::shared_ptr WstringArraySamplePtr; typedef Alembic::Util::shared_ptr V2sArraySamplePtr; typedef Alembic::Util::shared_ptr V2iArraySamplePtr; typedef Alembic::Util::shared_ptr V2fArraySamplePtr; typedef Alembic::Util::shared_ptr V2dArraySamplePtr; typedef Alembic::Util::shared_ptr V3sArraySamplePtr; typedef Alembic::Util::shared_ptr V3iArraySamplePtr; typedef Alembic::Util::shared_ptr V3fArraySamplePtr; typedef Alembic::Util::shared_ptr V3dArraySamplePtr; typedef Alembic::Util::shared_ptr P2sArraySamplePtr; typedef Alembic::Util::shared_ptr P2iArraySamplePtr; typedef Alembic::Util::shared_ptr P2fArraySamplePtr; typedef Alembic::Util::shared_ptr P2dArraySamplePtr; typedef Alembic::Util::shared_ptr P3sArraySamplePtr; typedef Alembic::Util::shared_ptr P3iArraySamplePtr; typedef Alembic::Util::shared_ptr P3fArraySamplePtr; typedef Alembic::Util::shared_ptr P3dArraySamplePtr; typedef Alembic::Util::shared_ptr Box2sArraySamplePtr; typedef Alembic::Util::shared_ptr Box2iArraySamplePtr; typedef Alembic::Util::shared_ptr Box2fArraySamplePtr; typedef Alembic::Util::shared_ptr Box2dArraySamplePtr; typedef Alembic::Util::shared_ptr Box3sArraySamplePtr; typedef Alembic::Util::shared_ptr Box3iArraySamplePtr; typedef Alembic::Util::shared_ptr Box3fArraySamplePtr; typedef Alembic::Util::shared_ptr Box3dArraySamplePtr; typedef Alembic::Util::shared_ptr M33fArraySamplePtr; typedef Alembic::Util::shared_ptr M33dArraySamplePtr; typedef Alembic::Util::shared_ptr M44fArraySamplePtr; typedef Alembic::Util::shared_ptr M44dArraySamplePtr; typedef Alembic::Util::shared_ptr QuatfArraySamplePtr; typedef Alembic::Util::shared_ptr QuatdArraySamplePtr; typedef Alembic::Util::shared_ptr C3hArraySamplePtr; typedef Alembic::Util::shared_ptr C3fArraySamplePtr; typedef Alembic::Util::shared_ptr C3cArraySamplePtr; typedef Alembic::Util::shared_ptr C4hArraySamplePtr; typedef Alembic::Util::shared_ptr C4fArraySamplePtr; typedef Alembic::Util::shared_ptr C4cArraySamplePtr; typedef Alembic::Util::shared_ptr N2fArraySamplePtr; typedef Alembic::Util::shared_ptr N2dArraySamplePtr; typedef Alembic::Util::shared_ptr N3fArraySamplePtr; typedef Alembic::Util::shared_ptr N3dArraySamplePtr; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/Abc/TypedPropertyTraits.h000066400000000000000000000213471507001531700221140ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_Abc_TypedPropertyTraits_h #define Alembic_Abc_TypedPropertyTraits_h #include //-***************************************************************************** // The property traits class maps ValueTypes with their protocol // strings. namespace Alembic { namespace Abc { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //-***************************************************************************** // This macro relies on there being a default constructor for the type // VAL #define ALEMBIC_ABC_DECLARE_TYPE_TRAITS( VAL, POD, EXTENT, INTERP, PTDEF ) \ struct PTDEF \ { \ static const PlainOldDataType pod_enum = POD; \ static const int extent = EXTENT; \ typedef VAL value_type; \ static const char * interpretation() { return ( INTERP ) ; } \ static const char * name() { return #PTDEF; } \ static AbcA::DataType dataType() \ { return AbcA::DataType( POD, EXTENT ) ; } \ static value_type defaultValue() \ { value_type v; return v; } \ } //-***************************************************************************** //-***************************************************************************** #define DECLARE_POD_TRAITS( POD_TYPE , PTDEF ) \ struct PTDEF \ { \ static const PlainOldDataType pod_enum = \ PODTraitsFromType< POD_TYPE >::pod_enum; \ static const int extent = 1; \ typedef POD_TYPE value_type; \ static const char * interpretation() { return ""; } \ static const char * name() { return #PTDEF; } \ static AbcA::DataType dataType() \ { return AbcA::DataType( PODTraitsFromType< POD_TYPE >::pod_enum, 1 ); } \ static value_type defaultValue() \ { return PODTraitsFromType< POD_TYPE >::default_value(); } \ } //-***************************************************************************** DECLARE_POD_TRAITS( bool_t, BooleanTPTraits ); DECLARE_POD_TRAITS( uint8_t, Uint8TPTraits ); DECLARE_POD_TRAITS( int8_t, Int8TPTraits ); DECLARE_POD_TRAITS( uint16_t, Uint16TPTraits ); DECLARE_POD_TRAITS( int16_t, Int16TPTraits ); DECLARE_POD_TRAITS( uint32_t, Uint32TPTraits ); DECLARE_POD_TRAITS( int32_t, Int32TPTraits ); DECLARE_POD_TRAITS( uint64_t, Uint64TPTraits ); DECLARE_POD_TRAITS( int64_t, Int64TPTraits ); DECLARE_POD_TRAITS( float16_t, Float16TPTraits ); DECLARE_POD_TRAITS( float32_t, Float32TPTraits ); DECLARE_POD_TRAITS( float64_t, Float64TPTraits ); DECLARE_POD_TRAITS( string, StringTPTraits ); DECLARE_POD_TRAITS( wstring, WstringTPTraits ); #undef DECLARE_POD_TRAITS //-***************************************************************************** ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2s, kInt16POD, 2, "vector", V2sTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2i, kInt32POD, 2, "vector", V2iTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2f, kFloat32POD, 2, "vector", V2fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2d, kFloat64POD, 2, "vector", V2dTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3s, kInt16POD, 3, "vector", V3sTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3i, kInt32POD, 3, "vector", V3iTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3f, kFloat32POD, 3, "vector", V3fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3d, kFloat64POD, 3, "vector", V3dTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2s, kInt16POD, 2, "point", P2sTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2i, kInt32POD, 2, "point", P2iTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2f, kFloat32POD, 2, "point", P2fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2d, kFloat64POD, 2, "point", P2dTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3s, kInt16POD, 3, "point", P3sTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3i, kInt32POD, 3, "point", P3iTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3f, kFloat32POD, 3, "point", P3fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V3d, kFloat64POD, 3, "point", P3dTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box2s, kInt16POD, 4, "box", Box2sTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box2i, kInt32POD, 4, "box", Box2iTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box2f, kFloat32POD, 4, "box", Box2fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box2d, kFloat64POD, 4, "box", Box2dTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box3s, kInt16POD, 6, "box", Box3sTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box3i, kInt32POD, 6, "box", Box3iTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box3f, kFloat32POD, 6, "box", Box3fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Box3d, kFloat64POD, 6, "box", Box3dTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( M33f, kFloat32POD, 9, "matrix", M33fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( M33d, kFloat64POD, 9, "matrix", M33dTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( M44f, kFloat32POD, 16, "matrix", M44fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( M44d, kFloat64POD, 16, "matrix", M44dTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Quatf, kFloat32POD, 4, "quat", QuatfTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( Quatd, kFloat64POD, 4, "quat", QuatdTPTraits ); //-***************************************************************************** // colors. For now, using "rgb"/"rgba" as the interpretation ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C3h, kFloat16POD, 3, "rgb", C3hTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C3f, kFloat32POD, 3, "rgb", C3fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C3c, kUint8POD, 3, "rgb", C3cTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C4h, kFloat16POD, 4, "rgba", C4hTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C4f, kFloat32POD, 4, "rgba", C4fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( C4c, kUint8POD, 4, "rgba", C4cTPTraits ); //-***************************************************************************** // Normals. ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2f, kFloat32POD, 2, "normal", N2fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( V2d, kFloat64POD, 2, "normal", N2dTPTraits ); // N3f and N3d is typedefed in Foundation from V3f and V3d ALEMBIC_ABC_DECLARE_TYPE_TRAITS( N3f, kFloat32POD, 3, "normal", N3fTPTraits ); ALEMBIC_ABC_DECLARE_TYPE_TRAITS( N3d, kFloat64POD, 3, "normal", N3dTPTraits ); } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace Abc } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCollection/000077500000000000000000000000001507001531700177275ustar00rootroot00000000000000alembic-1.8.9/lib/Alembic/AbcCollection/All.h000066400000000000000000000040721507001531700206130ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCollection_All_h #define Alembic_AbcCollection_All_h #include #include #include #endif alembic-1.8.9/lib/Alembic/AbcCollection/CMakeLists.txt000066400000000000000000000042411507001531700224700ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** LIST(APPEND CXX_FILES AbcCollection/OCollections.cpp AbcCollection/ICollections.cpp ) SET(CXX_FILES "${CXX_FILES}" PARENT_SCOPE) INSTALL(FILES All.h SchemaInfoDeclarations.h OCollections.h ICollections.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Alembic/AbcCollection ) IF (USE_TESTS) ADD_SUBDIRECTORY(Tests) ENDIF() alembic-1.8.9/lib/Alembic/AbcCollection/ICollections.cpp000066400000000000000000000076721507001531700230360ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCollection { namespace ALEMBIC_VERSION_NS { void ICollectionsSchema::init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICollectionsSchema::init()" ); AbcCoreAbstract::CompoundPropertyReaderPtr _this = this->getPtr(); m_collections.clear(); size_t numProps = this->getNumProperties(); for ( size_t i = 0; i < numProps; ++i ) { AbcCoreAbstract::PropertyHeader header = this->getPropertyHeader( i ); if ( Abc::IStringArrayProperty::matches( header ) ) { m_collections.push_back( Abc::IStringArrayProperty( _this, header.getName(), iArg0, iArg1 ) ); } } ALEMBIC_ABC_SAFE_CALL_END(); } Abc::IStringArrayProperty ICollectionsSchema::getCollection( size_t i ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICollectionsSchema::getCollection(size_t)" ); if ( i < m_collections.size() ) { return m_collections[i]; } ALEMBIC_ABC_SAFE_CALL_END(); return Abc::IStringArrayProperty(); } Abc::IStringArrayProperty ICollectionsSchema::getCollection( const std::string & iName ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICollectionsSchema::getCollection(string)" ); const AbcCoreAbstract::PropertyHeader * header = this->getPropertyHeader( iName ); if ( header != NULL && Abc::IStringArrayProperty::matches( *header ) ) { AbcCoreAbstract::CompoundPropertyReaderPtr _this = this->getPtr(); Abc::IStringArrayProperty prop( _this, iName ); return prop; } ALEMBIC_ABC_SAFE_CALL_END(); return Abc::IStringArrayProperty(); } std::string ICollectionsSchema::getCollectionName( size_t i ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "ICollectionsSchema::getCollectionName" ); if ( i < m_collections.size() ) { return m_collections[i].getName(); } ALEMBIC_ABC_SAFE_CALL_END(); return std::string(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCollection } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCollection/ICollections.h000066400000000000000000000113601507001531700224700ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2015, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCollections_ICollections_h #define Alembic_AbcCollections_ICollections_h #include #include #include namespace Alembic { namespace AbcCollection { namespace ALEMBIC_VERSION_NS { class ALEMBIC_EXPORT ICollectionsSchema : public Abc::ISchema { public: typedef ICollectionsSchema this_type; // default constructor creates an empty ICollectionSchema ICollectionsSchema() {} //! This constructor creates a new collections reader. //! The first argument is the parent ICompoundProperty, from which the //! error handler policy for is derived. The second argument is the name //! of the ICompoundProperty that contains this schemas properties. The //! remaining optional arguments can be used to override the //! ErrorHandlerPolicy and to specify schema interpretation matching. ICollectionsSchema( const ICompoundProperty &iParent, const std::string &iName, const Abc::Argument &iArg0 = Abc::Argument(), const Abc::Argument &iArg1 = Abc::Argument()) : Abc::ISchema( iParent, iName, iArg0, iArg1 ) { init( iArg0, iArg1 ); } //! This constructor wraps an existing ICompoundProperty as the collection //! reader, and the error handler policy is derived from it. //! The remaining optional arguments can be used to override the //! ErrorHandlerPolicy and to specify schema interpretation matching. ICollectionsSchema( const ICompoundProperty &iProp, const Abc::Argument &iArg0 = Abc::Argument(), const Abc::Argument &iArg1 = Abc::Argument() ) : Abc::ISchema( iProp, iArg0, iArg1 ) { init( iArg0, iArg1 ); } //! Returns the number of collections that we have size_t getNumCollections() { return m_collections.size(); } //! Return a collection by index Abc::IStringArrayProperty getCollection( size_t i ); //! Return a collection by name Abc::IStringArrayProperty getCollection( const std::string & iName ); //! Returns the name of a collection at a given index std::string getCollectionName( size_t i ); //! Returns whether this function set is valid. bool valid() const { return ( Abc::ISchema::valid() ); } protected: void init( const Abc::Argument &iArg0, const Abc::Argument &iArg1 ); std::vector< Abc::IStringArrayProperty > m_collections; }; //! Object declaration typedef Abc::ISchemaObject ICollections; typedef Util::shared_ptr< ICollections > ICollectionsPtr; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCollection } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCollection/OCollections.cpp000066400000000000000000000116231507001531700230330ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCollection { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** OCollectionsSchema::OCollectionsSchema( Alembic::AbcCoreAbstract::CompoundPropertyWriterPtr iParent, const std::string &iName, const Abc::Argument &iArg0, const Abc::Argument &iArg1, const Abc::Argument &iArg2, const Abc::Argument &iArg3 ) : Abc::OSchema( iParent, iName, iArg0, iArg1, iArg2, iArg3 ) { } //-***************************************************************************** OCollectionsSchema::OCollectionsSchema( Abc::OCompoundProperty iParent, const std::string &iName, const Abc::Argument &iArg0, const Abc::Argument &iArg1, const Abc::Argument &iArg2) : Abc::OSchema( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent ), iArg0, iArg1, iArg2 ) { } //-***************************************************************************** Abc::OStringArrayProperty OCollectionsSchema::createCollection( const std::string &iName, const Abc::Argument &iArg0, const Abc::Argument &iArg1, const Abc::Argument &iArg2 ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCollectionsSchema::createCollection" ); Abc::OStringArrayProperty prop = getCollection( iName ); if ( prop.valid() ) return prop; prop = Abc::OStringArrayProperty( this->getPtr(), iName, iArg0, iArg1, iArg2 ); if ( prop.valid() ) { m_collections.push_back( prop ); return prop; } ALEMBIC_ABC_SAFE_CALL_END(); return Abc::OStringArrayProperty(); } //-***************************************************************************** Abc::OStringArrayProperty OCollectionsSchema::getCollection( size_t i ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCollectionsSchema::getCollection(size_t)" ); if ( i < m_collections.size() ) { return m_collections[i]; } ALEMBIC_ABC_SAFE_CALL_END(); return Abc::OStringArrayProperty(); } //-***************************************************************************** Abc::OStringArrayProperty OCollectionsSchema::getCollection( const std::string & iName ) { ALEMBIC_ABC_SAFE_CALL_BEGIN( "OCollectionsSchema::getCollection(string)" ); const AbcCoreAbstract::PropertyHeader * header = this->getPropertyHeader( iName ); if ( header != NULL && Abc::OStringArrayProperty::matches( *header ) ) { Abc::OStringArrayProperty prop( this->getProperty( iName ).getPtr()->asArrayPtr() ); return prop; } ALEMBIC_ABC_SAFE_CALL_END(); return Abc::OStringArrayProperty(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCollection } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCollection/OCollections.h000066400000000000000000000117651507001531700225070ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2015, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCollection_OCollections_h #define Alembic_AbcCollection_OCollections_h #include #include #include namespace Alembic { namespace AbcCollection { namespace ALEMBIC_VERSION_NS { class ALEMBIC_EXPORT OCollectionsSchema : public Abc::OSchema { public: typedef OCollectionsSchema this_type; OCollectionsSchema() {} //! This constructor creates a new collections writer. //! The first argument is an CompoundPropertyWriterPtr to use as a parent. //! The next is the name to give the schema which is usually the default //! name given by OCollections (.collection) The remaining optional //! arguments can be used to override the ErrorHandlerPolicy, to specify //! MetaData, specify sparse sampling and to set TimeSampling. OCollectionsSchema( Alembic::AbcCoreAbstract::CompoundPropertyWriterPtr iParent, const std::string &iName, const Abc::Argument &iArg0 = Abc::Argument(), const Abc::Argument &iArg1 = Abc::Argument(), const Abc::Argument &iArg2 = Abc::Argument(), const Abc::Argument &iArg3 = Abc::Argument() ); //! This constructor creates a new collections writer. //! The first argument is an OCompundProperty to use as a parent, and from //! which the ErrorHandlerPolicy is derived. The next is the name to give //! the schema which is usually the default name given by OCollections //! (.collection) The remaining optional arguments can be used to specify //! MetaData, specify sparse sampling and to set TimeSampling. OCollectionsSchema( Abc::OCompoundProperty iParent, const std::string &iName, const Abc::Argument &iArg0 = Abc::Argument(), const Abc::Argument &iArg1 = Abc::Argument(), const Abc::Argument &iArg2 = Abc::Argument() ); //! Create a named collection, if the collection already exists //! return it. Abc::OStringArrayProperty createCollection( const std::string &iName, const Abc::Argument &iArg0 = Abc::Argument(), const Abc::Argument &iArg1 = Abc::Argument(), const Abc::Argument &iArg2 = Abc::Argument() ); //! Returns the number of collections that we have size_t getNumCollections() { return m_collections.size(); } //! Return a collection by index Abc::OStringArrayProperty getCollection( size_t i ); //! Return a collection by name Abc::OStringArrayProperty getCollection( const std::string & iName ); //! Returns whether this function set is valid. bool valid() const { return ( Abc::OSchema::valid() ); } protected: std::vector< Abc::OStringArrayProperty > m_collections; }; //! Object declaration typedef Abc::OSchemaObject OCollections; typedef Util::shared_ptr< OCollections > OCollectionsPtr; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCollection } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCollection/SchemaInfoDeclarations.h000066400000000000000000000045651507001531700244570ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCollection_SchemaInfoDeclarations_h #define Alembic_AbcCollection_SchemaInfoDeclarations_h #include namespace Alembic { namespace AbcCollection { namespace ALEMBIC_VERSION_NS { ALEMBIC_ABC_DECLARE_SCHEMA_INFO( "AbcCollection_Collections_v1", "", ".collection", false, CollectionsSchemaInfo ); } using namespace ALEMBIC_VERSION_NS; } } #endif alembic-1.8.9/lib/Alembic/AbcCollection/Tests/000077500000000000000000000000001507001531700210315ustar00rootroot00000000000000alembic-1.8.9/lib/Alembic/AbcCollection/Tests/CMakeLists.txt000066400000000000000000000041561507001531700235770ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib) ADD_EXECUTABLE(AbcCollection_CollectionTest CollectionTest.cpp ) TARGET_LINK_LIBRARIES(AbcCollection_CollectionTest Alembic) ADD_TEST(AbcCollection_Collection_TEST AbcCollection_CollectionTest) alembic-1.8.9/lib/Alembic/AbcCollection/Tests/CollectionTest.cpp000066400000000000000000000114201507001531700244660ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include namespace Abc = Alembic::Abc; namespace AbcCol = Alembic::AbcCollection; namespace AbcA = Alembic::AbcCoreAbstract; void write() { Abc::OArchive archive(Alembic::AbcCoreOgawa::WriteArchive(), "Collection.abc" ); Abc::OObject root(archive, Abc::kTop); Abc::OObject test(root, "test"); AbcA::TimeSamplingPtr ts ( new AbcA::TimeSampling( 1/24.0, 2.0 ) ); AbcA::MetaData md; md.set("coupe", "de ville"); AbcCol::OCollections group(test, "Group1"); AbcCol::OCollections group2(test, "Group2"); std::vector< std::string > strVec; strVec.push_back("/a/b/c/1"); strVec.push_back("/a/b/c/2"); strVec.push_back("/a/b/c/3"); Abc::OStringArrayProperty prop; prop = group.getSchema().createCollection("prop"); prop.set(Abc::StringArraySample(strVec)); TESTING_ASSERT(group.getSchema().getNumCollections() == 1); { group.getSchema().createCollection("cool", md, ts); TESTING_ASSERT( group.getSchema().getCollection(1).getMetaData().get("coupe") == "de ville"); strVec.clear(); strVec.push_back("/foo"); strVec.push_back("/bar"); group.getSchema().getCollection(1).set(Abc::StringArraySample(strVec)); } strVec.clear(); strVec.push_back("potato"); group.getSchema().getCollection("cool").set(Abc::StringArraySample(strVec)); } void read() { Abc::IArchive archive(Alembic::AbcCoreOgawa::ReadArchive(), "Collection.abc"); Abc::IObject test(archive.getTop(), "test"); AbcCol::ICollections group(test, "Group1"); AbcCol::ICollections group2(test, "Group2"); TESTING_ASSERT(group.getSchema().getNumCollections() == 2); TESTING_ASSERT(group2.getSchema().getNumCollections() == 0); TESTING_ASSERT(!group2.getSchema().getCollection(45)); TESTING_ASSERT(!group2.getSchema().getCollection("potato")); Abc::IStringArrayProperty prop = group.getSchema().getCollection("prop"); Abc::IStringArrayProperty prop2 = group.getSchema().getCollection("cool"); TESTING_ASSERT(group.getSchema().getCollection(0).getName() == "cool" || group.getSchema().getCollection(0).getName() == "prop"); TESTING_ASSERT(group.getSchema().getCollection(1).getName() == "cool" || group.getSchema().getCollection(1).getName() == "prop"); TESTING_ASSERT(prop2.getMetaData().get("coupe") == "de ville"); TESTING_ASSERT(archive.getTimeSampling(1) == prop2.getTimeSampling()); TESTING_ASSERT(prop2.getNumSamples() == 2); Abc::StringArraySamplePtr samp = prop.getValue(0); TESTING_ASSERT(samp->size() == 3); TESTING_ASSERT((*samp)[0] == "/a/b/c/1"); TESTING_ASSERT((*samp)[1] == "/a/b/c/2"); TESTING_ASSERT((*samp)[2] == "/a/b/c/3"); } int main(int argc, char *argv[]) { write(); read(); return 0; } alembic-1.8.9/lib/Alembic/AbcCoreAbstract/000077500000000000000000000000001507001531700202105ustar00rootroot00000000000000alembic-1.8.9/lib/Alembic/AbcCoreAbstract/All.h000066400000000000000000000062411507001531700210740ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_All_h #define Alembic_AbcCoreAbstract_All_h #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ArchiveReader.cpp000066400000000000000000000043271507001531700234260ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** ArchiveReader::~ArchiveReader() { // Nothing } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ArchiveReader.h000066400000000000000000000135571507001531700231000ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ArchiveReader_h #define Alembic_AbcCoreAbstract_ArchiveReader_h #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! In order for an implementation to concretely provide a starting point //! for using the abstract API, a single "explicitly linked" function to //! start from is necessary. That function will return, in the case of reading, //! an ArchiveReaderPtr. This typedef provides a signature that such a function //! should adhere to. This idiom is a workaround for the lack of virtual //! constructors in C++, and to avoid creating another class (such as //! "Implementation" or something similar) //! This is provided here as an illustration. It does not need to be //! derived from explicitly. namespace IllustrationOnly { struct ALEMBIC_EXPORT ArchiveReaderConstructor { // Create whatever cache is the default caching mechanism associated // with the archive reader implementation ArchiveReaderPtr operator()( const std::string &iFileName ); // Use the explicitly supplied cache implementation. ArchiveReaderPtr operator()( const std::string &iFileName, ReadArraySampleCachePtr iCachePtr ); }; } // End namespace IllustrationOnly //-***************************************************************************** //! The Archive is "the file". It has a single object, it's top object. //! It has no properties, but does have metadata. class ALEMBIC_EXPORT ArchiveReader : private Alembic::Util::noncopyable { public: //! Virtual destructor //! ... virtual ~ArchiveReader(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! Return the archive (file) name. This is the name of the file //! which the root reader is associated with. virtual const std::string &getName() const = 0; //! The meta data of the archive is the same as the meta data //! of the top-level object reader. virtual const MetaData &getMetaData() const = 0; //! Get (or open) a pointer to the top object reader //! corresponding to this archive. virtual ObjectReaderPtr getTop() = 0; //! Get the read array sample cache. It may be a NULL pointer. //! Caches can be shared amongst separate archives, and caching //! will is disabled if a NULL cache is returned here. virtual ReadArraySampleCachePtr getReadArraySampleCachePtr() = 0; //! Set the read array sample cache. It may also be a NULL pointer. //! Caches can be shared amongst separate archives, and caching //! will be disabled if a NULL cache is passed here. virtual void setReadArraySampleCachePtr( ReadArraySampleCachePtr iPtr ) = 0; //! Returns the TimeSampling at a given index. virtual TimeSamplingPtr getTimeSampling( uint32_t iIndex ) = 0; //! Returns the maximum number of samples written for the TimeSampling at //! the given index. If an illegal iIndex is specified, or a max //! number of samplings couldn't be found for that iIndex //! (for older archives pre 1.1.3) INDEX_UNKNOWN will be returned. virtual index_t getMaxNumSamplesForTimeSamplingIndex( uint32_t iIndex ) = 0; //! Returns the total number of TimeSamplingPtrs in the Archive //! TimeSampling pool. virtual uint32_t getNumTimeSamplings() = 0; //! Returns the Alembic library numeric version (see Foundation.h) //! of this archive file. virtual int32_t getArchiveVersion() = 0; //! Return self //! ... virtual ArchiveReaderPtr asArchivePtr() = 0; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ArchiveWriter.cpp000066400000000000000000000043271507001531700235000ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** ArchiveWriter::~ArchiveWriter() { // Nothing } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ArchiveWriter.h000066400000000000000000000144631507001531700231470ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ArchiveWriter_h #define Alembic_AbcCoreAbstract_ArchiveWriter_h #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! In order for an implementation to concretely provide a starting point //! for using the abstract API, a single "explicitly linked" function to //! start from is necessary. That function will return, in the case of writing, //! an ArchiveWriterPtr. This typedef provides a signature that such a function //! should adhere to. This idiom is a workaround for the lack of virtual //! constructors in C++, and to avoid creating another class (such as //! "Implementation" or something similar) namespace IllustrationOnly { struct ALEMBIC_EXPORT ArchiveWriterConstructor { // Create an archive writer with the given file name and meta data. ArchiveWriterPtr operator()( const std::string &iFileName, const MetaData &iMetaData ); }; } // End namespace IllustrationOnly //-***************************************************************************** //! The Archive is "the file". It has a single object, it's top object. //! It has no properties, but does have metadata. class ALEMBIC_EXPORT ArchiveWriter : private Alembic::Util::noncopyable { protected: ArchiveWriter() : m_compressionHint( -1 ) {} public: //! Virtual destructor //! ... virtual ~ArchiveWriter(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! Return the archive (file) name. This is the name of the file //! which the archive writer is associated with. virtual const std::string &getName() const = 0; //! The meta data of the archive is the same as the meta data //! of the top-level object writer. virtual const MetaData &getMetaData() const = 0; //! Get the top object writer. //! Archives always have this single top-level object created //! automatically. virtual ObjectWriterPtr getTop() = 0; //! Get the compression applied to array properties. //! Implementations are free to disregard this. int8_t getCompressionHint() const { return m_compressionHint; } //! Set the compression applied to array properties. //! Implementations are free to disregard this. //! -1 means off, 0 means "litte", where 9 means "alot" void setCompressionHint( int8_t iCh ) { m_compressionHint = iCh < -1 ? -1 : ( iCh > 9 ? 9 : iCh ); } //! Return self //! May sometimes be spoofed. virtual ArchiveWriterPtr asArchivePtr() = 0; //! Adds the TimeSampling to the Archive TimeSampling pool. //! If the TimeSampling already exists in the pool, the index for the match //! should be returned. //! index 0 is automatically reserved for uniform time sampling with a start //! time of 0 and time per cycle of 1 (aka identity sampling) virtual uint32_t addTimeSampling( const TimeSampling & iTs ) = 0; //! Returns the TimeSampling at a given index. //! index 0 is automatically reserved for uniform time sampling with a start //! time of 0 and time per cycle of 1 (aka identity sampling) virtual TimeSamplingPtr getTimeSampling( uint32_t iIndex ) = 0; //! Returns the total number of TimeSamplingPtrs in the Archive //! TimeSampling pool. virtual uint32_t getNumTimeSamplings() = 0; //! Returns the maximum number of samples written for the TimeSampling at //! the given index. If an illegal iIndex is specified, INDEX_UNKNOWN //! will be returned. virtual index_t getMaxNumSamplesForTimeSamplingIndex( uint32_t iIndex ) = 0; //! Sets the maximum number of samples written for the TimeSampling at //! the given index. You normally don't need to call this as the //! properties will call it at the appropriate time. virtual void setMaxNumSamplesForTimeSamplingIndex( uint32_t iIndex, index_t iMaxIndex ) = 0; private: int8_t m_compressionHint; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ArrayPropertyReader.cpp000066400000000000000000000043471507001531700246720ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** ArrayPropertyReader::~ArrayPropertyReader() { // Nothing } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ArrayPropertyReader.h000066400000000000000000000160301507001531700243270ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ArrayPropertyReader_h #define Alembic_AbcCoreAbstract_ArrayPropertyReader_h #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! An Array Property is a Rank N (usually 1-3) property which has a //! multidimensional array of identically typed values for each //! sample. This is distinguished from a Simple Property, which has a //! single element per sample, and requires less sophisticated //! resource management. class ALEMBIC_EXPORT ArrayPropertyReader : public BasePropertyReader { public: //! Virtual destructor //! ... virtual ~ArrayPropertyReader(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! Return the number of samples contained in the property. //! This can be any number, including zero. //! This returns the number of samples that were written, independently //! of whether or not they were constant. Implementations may (and should) //! choose to condense identical samples. virtual size_t getNumSamples() = 0; //! Ask if we're constant - no change in value amongst samples, //! regardless of the time sampling. virtual bool isConstant() = 0; //! It returns a shared pointer to a thing which _is_ the data, in a //! locked and retrieved form. This represents the point of demand, //! not below here. //! Implementations of this library can (and should) utilize the //! custom-deleter capabilities of the smart_ptr to add locking and //! unlocking access to cache or management code. //! It will throw an exception on an out-of-range access. //! Though it could technically return the pointer by value efficiently //! enough, we return by reference so that the calling signature //! mirrors the ScalarPropertyReader. //! //! For each DataType, the ( void * ) data buffer returned in the //! array sample points to one data element, which in the case of //! DataType( kStringPOD, 1 ) and DataType( kWstringPOD, 1 ) are //! arrays of std::string and std::wstring, respectively. virtual void getSample( index_t iSampleIndex, ArraySamplePtr &oSample ) = 0; //! Find the largest valid index that has a time less than or equal //! to the given time. Invalid to call this with zero samples. //! If the minimum sample time is greater than iTime, index //! 0 will be returned. virtual std::pair getFloorIndex( chrono_t iTime ) = 0; //! Find the smallest valid index that has a time greater //! than the given time. Invalid to call this with zero samples. //! If the maximum sample time is less than iTime, index //! numSamples-1 will be returned. virtual std::pair getCeilIndex( chrono_t iTime ) = 0; //! Find the valid index with the closest time to the given //! time. Invalid to call this with zero samples. virtual std::pair getNearIndex( chrono_t iTime ) = 0; //! Expose the key for apps that use their own custom cache management. virtual bool getKey( index_t iSampleIndex, ArraySampleKey & oKey ) = 0; //! The ArraySample may have incorrect dimensions, (even though the packed //! data will be correct) expose the correct dimensions here for those //! clients that need it. virtual void getDimensions( index_t iSampleIndex, Dimensions & oDim ) = 0; //! A hint about whether this property has 1 and only 1 DataType //! for each of it's samples. Array Properties with no samples written to //! it are still considered scalar like. virtual bool isScalarLike() = 0; //! Reads the data for the requested sample into the memory location //! specified by iIntoLocation as the requested POD type specified by iPod. //! Out-of-range indices, or incompatible POD types will cause an //! exception to be thrown. //! //! Incompatible POD types include trying to read a std::string, //! std::wstring, or float16_t as anything OTHER than itself. //! //! In all cases EXCEPT String and Wstring, the iPod type and the total //! number of items from getDimensions for this property can be used to //! determine the size of the memory buffer which iIntoLocation must point //! to. In the case of String and Wstring, //! iIntoLocation should be an array of std::string or std::wstring. //! //! This is one of the only places where we break from POD types at //! the base, and we're making an explicit decision to use std::string //! and std::wstring as core language-level primitives. virtual void getAs( index_t iSample, void *iIntoLocation, PlainOldDataType iPod ) = 0; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ArrayPropertyWriter.cpp000066400000000000000000000043471507001531700247440ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** ArrayPropertyWriter::~ArrayPropertyWriter() { // Nothing } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ArrayPropertyWriter.h000066400000000000000000000101511507001531700243770ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ArrayPropertyWriter_h #define Alembic_AbcCoreAbstract_ArrayPropertyWriter_h #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! An Array Property is a Rank N (usually 1-3) property which has a //! multidimensional array of identically typed values for each //! sample. This is distinguished from a Simple Property, which has a //! single element per sample, and requires less sophisticated //! resource management. class ALEMBIC_EXPORT ArrayPropertyWriter : public BasePropertyWriter { public: //! Virtual destructor //! ... virtual ~ArrayPropertyWriter(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! Sets a sample //! //! This takes a read-only ArraySample by const reference. The class //! will make an internal copy (or the functional equivalent of ), //! and will not use that memory block outside the scope of this //! function call. //! //! Arrays of std::string and std::wstring are assumed to be //! treated just like regular data elements. virtual void setSample( const ArraySample & iSamp ) = 0; //! Set the next sample to equal the previous sample. //! An important feature! virtual void setFromPreviousSample() = 0; //! Return the number of samples that have been written so far. //! This changes as samples are written. virtual size_t getNumSamples() = 0; //! Changes the TimeSampling used by this property. //! If the TimeSampling is changed to Acyclic and the number of samples //! currently set is more than the number of times provided in the Acyclic //! TimeSampling, an exception will be thrown. virtual void setTimeSamplingIndex( uint32_t iIndex ) = 0; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ArraySample.cpp000066400000000000000000000137671507001531700231520ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** ArraySample::Key ArraySample::getKey() const { // Depending on data type, loop over everything. size_t numPoints = m_dimensions.numPoints(); size_t numPods = m_dataType.getExtent() * numPoints; size_t numBytes = m_dataType.getNumBytes() * numPoints; ArraySample::Key k; k.numBytes = numBytes; k.origPOD = m_dataType.getPod(); k.readPOD = k.origPOD; switch ( m_dataType.getPod() ) { case kBooleanPOD: case kUint8POD: case kInt8POD: case kUint16POD: case kInt16POD: case kUint32POD: case kInt32POD: case kUint64POD: case kInt64POD: case kFloat16POD: case kFloat32POD: case kFloat64POD: { MurmurHash3_x64_128( m_data, numBytes, PODNumBytes(m_dataType.getPod()), k.digest.words ); } break; case kStringPOD: { std::vector v; for ( size_t j = 0; j < numPods; ++j ) { const std::string &str = static_cast( m_data )[j]; size_t strLen = str.length(); for ( size_t k = 0; k < strLen; ++k ) { v.push_back(str[k]); } // append a 0 for the NULL seperator character v.push_back(0); } int8_t * vptr = NULL; if ( !v.empty() ) vptr = &(v.front()); MurmurHash3_x64_128( vptr, v.size(), sizeof(int8_t), k.digest.words ); } break; case kWstringPOD: { std::vector v; for ( size_t j = 0; j < numPods; ++j ) { const std::wstring &wstr = static_cast( m_data )[j]; size_t wlen = wstr.length(); for (size_t k = 0; k < wlen; ++k) { v.push_back(wstr[k]); } // append a 0 for the NULL seperator character v.push_back(0); } int32_t * vptr = NULL; if ( !v.empty() ) vptr = &(v.front()); MurmurHash3_x64_128( vptr, v.size(), sizeof(int32_t), k.digest.words ); } break; default: ABCA_THROW( "Can't calculate key for: " << m_dataType ); break; } return k; } //-***************************************************************************** ArraySamplePtr AllocateArraySample( const DataType &iDtype, const Dimensions &iDims ) { switch ( iDtype.getPod() ) { case kBooleanPOD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kUint8POD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kInt8POD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kUint16POD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kInt16POD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kUint32POD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kInt32POD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kUint64POD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kInt64POD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kFloat16POD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kFloat32POD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kFloat64POD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kStringPOD: return TAllocateArraySample( iDtype.getExtent(), iDims ); case kWstringPOD: return TAllocateArraySample( iDtype.getExtent(), iDims ); default: return ArraySamplePtr(); } } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ArraySample.h000066400000000000000000000176061507001531700226130ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ArraySample_h #define Alembic_AbcCoreAbstract_ArraySample_h #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! The ArraySample class is a reference to a block of memory corresponding //! to an array of instances of DataTypes. The array may be multi-rank, with //! different sizes in each dimension, but with its data ultimately stored //! contiguously. The class is basically just a bundle of a memory address, //! stored as a void*, a DataType, and a Dimension. //! //! The ArraySample itself does not pretend to own the data referred to //! memory address "data". It is just a reference. For data retention mgmt, //! see the note on \ref ArraySamplePtr below. class ALEMBIC_EXPORT ArraySample { public: typedef ArraySample this_type; typedef ArraySampleKey Key; typedef Key key_type; //! Default constructor creates NULL bytes with degenerate dimensions. //! ... ArraySample() : m_data( NULL ) , m_dataType() , m_dimensions() {} //! Explicit constructor takes bytes and dims by reference //! and creates its own reference to them. ArraySample( const void * iData, const DataType &iDataType, const Dimensions & iDims ) : m_data( iData ) , m_dataType( iDataType ) , m_dimensions( iDims ) {} //! Using Default Copy Constructor //! Using Default Assignment Operator //! Return the data as a raw pointer //! ... const void* getData() const { return m_data; } //! Return the datatype. //! ... const DataType &getDataType() const { return m_dataType; } //! Return the dimensions //! ... const Dimensions& getDimensions() const { return m_dimensions; } //! Return the "size", which is getDimensions().numPoints() //! ... size_t size() const { return m_dimensions.numPoints(); } //! Compute the Key. //! This is a calculation. Key getKey() const; //! Return if it is valid. //! An empty ArraySample is valid. //! however, an ArraySample that is empty and has a scalar //! dimension is invalid. This is how we discriminate between //! setting a sample of length zero (useful in particle systems) //! vs. indicating an invalid sample (NULL). bool valid() const { return ( m_dataType.getPod() != kUnknownPOD ) && !( m_data == NULL && m_dimensions.rank() < 1 ); } //! Reset the array sample to an empty, invalid state. //! Basically the same as calling *this = ArraySample(); void reset() { m_data = NULL; m_dataType = DataType(); m_dimensions = Dimensions(); } private: const void *m_data; DataType m_dataType; Dimensions m_dimensions; }; //-***************************************************************************** //! The ArraySamplePtr can be used not only to share this ArraySample, but //! also to manage the data referred to by the memory address in the pointer, //! by way of a custom deleter. In this manner, ArraySample and ArraySamplePtr //! can be used both as a reference to data and as an explicit ownership of //! data. This greatly reduces the redundancy of this library's code. typedef Alembic::Util::shared_ptr ArraySamplePtr; //-***************************************************************************** //! When creating an actual buffer for reading an array sample into, //! we need to allocate an array of some number of bytes, and then delete //! it with a special deleter. This function will return an array sample //! that is managed in this way. //! Dimensions tells us how many instances of the DataType to create //! DataType tells us what the instance is - and this works for //! pretty much every case, including std::string and std::wstring. ALEMBIC_EXPORT ArraySamplePtr AllocateArraySample( const DataType &iDtype, const Dimensions &iDims ); //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** // HELPER STUFF! //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** template struct TArrayDeleter { void operator()( void *memory ) const { ArraySample *arraySample = static_cast( memory ); if ( arraySample ) { T *data = reinterpret_cast( const_cast( arraySample->getData() ) ); // Delete[] NULL is okay. delete[] data; } delete arraySample; } }; //-***************************************************************************** template ArraySamplePtr TAllocateArraySample( size_t iDataTypeExtent, const Dimensions &iDims ) { DataType dtype( PODTraitsFromType::pod_enum, iDataTypeExtent ); size_t numPODs = iDims.numPoints() * iDataTypeExtent; if ( numPODs > 0 ) { T *data = new T[numPODs]; ArraySamplePtr ret( new ArraySample( reinterpret_cast( data ), dtype, iDims ), TArrayDeleter() ); return ret; } else { ArraySamplePtr ret( new ArraySample( ( const void * )NULL, dtype, iDims ) ); return ret; } } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ArraySampleKey.h000066400000000000000000000114071507001531700232550ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ArraySampleKey_h #define Alembic_AbcCoreAbstract_ArraySampleKey_h #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { struct ArraySampleKey : public Alembic::Util::totally_ordered { //! total number of bytes of the sample as originally stored uint64_t numBytes; //! Original POD as stored PlainOldDataType origPOD; //! POD used at read time PlainOldDataType readPOD; Digest digest; bool operator==( const ArraySampleKey &iRhs ) const { return ( ( numBytes == iRhs.numBytes ) && ( origPOD == iRhs.origPOD ) && ( readPOD == iRhs.readPOD ) && ( digest == iRhs.digest ) ); }; bool operator<( const ArraySampleKey &iRhs ) const { return ( numBytes < iRhs.numBytes ? true : ( numBytes > iRhs.numBytes ? false : ( origPOD < iRhs.origPOD ? true : ( origPOD > iRhs.origPOD ? false : ( readPOD < iRhs.readPOD ? true : ( readPOD > iRhs.readPOD ? false : ( digest < iRhs.digest ) ) ) ) ) ) ); }; }; //-***************************************************************************** // Equality operator. struct ArraySampleKeyEqualTo { typedef ArraySampleKey first_argument_type; typedef ArraySampleKey second_argument_type; typedef bool result_type; bool operator()( ArraySampleKey const &a, ArraySampleKey const &b ) const { return a == b; } }; //-***************************************************************************** // Hash function inline size_t StdHash( ArraySampleKey const &a ) { // Theoretically, the bits of our hash are uniformly // randomly distributed, so it doesn't matter which of the 128 // bits we use to generate the 64 bits that we return as the hash // key. So, I'll just do the simple thing. return *(( const size_t * )&a.digest); } //-***************************************************************************** struct ArraySampleKeyStdHash { typedef ArraySampleKey argument_type; typedef size_t result_type; size_t operator()( ArraySampleKey const &a ) const { return StdHash( a ); } }; //-***************************************************************************** template struct UnorderedMapUtil { typedef Alembic::Util::unordered_map umap_type; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/BasePropertyReader.cpp000066400000000000000000000055241507001531700244640ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** BasePropertyReader::~BasePropertyReader() { // Nothing } //-***************************************************************************** ScalarPropertyReaderPtr BasePropertyReader::asScalarPtr() { // An empty pointer. return ScalarPropertyReaderPtr(); } //-***************************************************************************** ArrayPropertyReaderPtr BasePropertyReader::asArrayPtr() { // An empty pointer. return ArrayPropertyReaderPtr(); } //-***************************************************************************** CompoundPropertyReaderPtr BasePropertyReader::asCompoundPtr() { // An empty pointer. return CompoundPropertyReaderPtr(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/BasePropertyReader.h000066400000000000000000000156701507001531700241340ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_BasePropertyReader_h #define Alembic_AbcCoreAbstract_BasePropertyReader_h #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! Base Property Reader. class ALEMBIC_EXPORT BasePropertyReader : private Alembic::Util::noncopyable { public: //! Virtual destructor //! ... virtual ~BasePropertyReader(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! Properties are created with a collection of metadata that is stored //! in a lightweight structure called PropertyHeader. //! This returns a constant reference to the PropertyHeader which //! was given upon creation. virtual const PropertyHeader & getHeader() const = 0; //! All properties have a name, which is unique amongst its siblings //! in the compund property they all live in. This is the name that //! was given when the property was created, and is part of the property //! header. const std::string &getName() const { return getHeader().getName(); } //! There are three types of abstract properties. //! They are Scalar, Array, and Compound properties. This function //! returns an enum PropertyType which indicates which property //! type is returned. This is simply a convenience function which //! returns data from the PropertyHeader. PropertyType getPropertyType() const { return getHeader().getPropertyType(); } //! Convenience to return whether the property is scalar. //! Same as getPropertyType() == kScalarProperty bool isScalar() const { return getPropertyType() == kScalarProperty; } //! Convenience to return whether the property is array. //! Same as getPropertyType() == kArrayProperty bool isArray() const { return getPropertyType() == kArrayProperty; } //! Convenience to return whether the property is compound. //! Same as getPropertyType() == kCompoundProperty bool isCompound() const { return getPropertyType() == kCompoundProperty; } //! Convenience to return whether the property is simple (non-compound) //! Same as getPropertyType() != kCompoundProperty bool isSimple() const { return !isCompound(); } //! All properties have MetaData. This just returns the //! MetaData portion of the header that was used in creation. const MetaData &getMetaData() const { return getHeader().getMetaData(); } //! Non-compound properties have a DataType. It is an error //! to call this function for CompoundProperties, and an exception will //! be thrown. This is a convenience function which just returns the //! DataType from the header that was used in creation. const DataType &getDataType() const { return getHeader().getDataType(); } //! Non-compound properties have a TimeSampling. It is an error //! to call this function for CompoundProperties, and an exception will //! be thrown. This is a convenience function which just returns the //! TimeSampling from the header that was used in creation. TimeSamplingPtr getTimeSampling() const { return getHeader().getTimeSampling(); } //! All properties have an object that owns them, and in order to //! ensure the object stays alive as long as the properties do, they //! retain a shared pointer to their object. virtual ObjectReaderPtr getObject() = 0; //! Most properties live in a compound property. (Except for //! the top-compound property in any object) //! This returns a pointer to the parent compound property. virtual CompoundPropertyReaderPtr getParent() = 0; //! Up-cast this base property to a ScalarProperty, if such an //! upcast is valid. This can be checked with the \ref isScalar() //! function. If the upcast is not valid, an empty pointer will //! be returned. This default implementation returns an empty //! pointer. virtual ScalarPropertyReaderPtr asScalarPtr(); //! Up-cast this base property to an ArrayProperty, if such an //! upcast is valid. This can be checked with the \ref isArray() //! function. If the upcast is not valid, an empty pointer will //! be returned. This default implementation returns an empty //! pointer. virtual ArrayPropertyReaderPtr asArrayPtr(); //! Up-cast this base property to a CompoundProperty, if such an //! upcast is valid. This can be checked with the \ref isCompound() //! function. If the upcast is not valid, an empty pointer will //! be returned. This default implementation returns an empty //! pointer. virtual CompoundPropertyReaderPtr asCompoundPtr(); }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/BasePropertyWriter.cpp000066400000000000000000000055241507001531700245360ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** BasePropertyWriter::~BasePropertyWriter() { // Nothing } //-***************************************************************************** ScalarPropertyWriterPtr BasePropertyWriter::asScalarPtr() { // An empty pointer. return ScalarPropertyWriterPtr(); } //-***************************************************************************** ArrayPropertyWriterPtr BasePropertyWriter::asArrayPtr() { // An empty pointer. return ArrayPropertyWriterPtr(); } //-***************************************************************************** CompoundPropertyWriterPtr BasePropertyWriter::asCompoundPtr() { // An empty pointer. return CompoundPropertyWriterPtr(); } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/BasePropertyWriter.h000066400000000000000000000164751507001531700242120ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_BasePropertyWriter_h #define Alembic_AbcCoreAbstract_BasePropertyWriter_h #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! The BasePropertyWriter is the base class for all properties, //! from Simple (which encompasses Scalar and Array properties) to //! Compound. The functions here establish the things which all properties //! have in common - name, metaData, propertyType, as well as //! upcasting capabilities. We don't want to rely on dynamic_cast - it's //! slow and potentially has problems across DSO interfaces. class ALEMBIC_EXPORT BasePropertyWriter : private Alembic::Util::noncopyable { public: //! Virtual destructor //! ... virtual ~BasePropertyWriter(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! Properties are created with a collection of metadata that is stored //! in a lightweight structure called PropertyHeader. //! This returns a constant reference to the PropertyHeader which //! was given upon creation. virtual const PropertyHeader & getHeader() const = 0; //! All properties have a name, which is unique amongst its siblings //! in the compund property they all live in. This is the name that //! was given when the property was created, and is part of the property //! header. const std::string &getName() const { return getHeader().getName(); } //! There are three types of abstract properties. //! They are Scalar, Array, and Compound properties. This function //! returns an enum PropertyType which indicates which property //! type is returned. This is simply a convenience function which //! returns data from the PropertyHeader. PropertyType getPropertyType() const { return getHeader().getPropertyType(); } //! Convenience to return whether the property is scalar. //! Same as getPropertyType() == kScalarProperty bool isScalar() const { return getPropertyType() == kScalarProperty; } //! Convenience to return whether the property is array. //! Same as getPropertyType() == kArrayProperty bool isArray() const { return getPropertyType() == kArrayProperty; } //! Convenience to return whether the property is compound. //! Same as getPropertyType() == kCompoundProperty bool isCompound() const { return getPropertyType() == kCompoundProperty; } //! Convenience to return whether the property is simple (non-compound) //! Same as getPropertyType() != kCompoundProperty bool isSimple() const { return !isCompound(); } //! All properties have MetaData. This just returns the //! MetaData portion of the header that was used in creation. const MetaData &getMetaData() const { return getHeader().getMetaData(); } //! Non-compound properties have a DataType. It is an error //! to call this function for CompoundProperties, and an exception will //! be thrown. This is a convenience function which just returns the //! DataType from the header that was used in creation. const DataType &getDataType() const { return getHeader().getDataType(); } //! Non-compound properties have a TimeSampling. It is an error //! to call this function for CompoundProperties, and an exception will //! be thrown. This is a convenience function which just returns the //! TimeSamplingType from the header that was used in creation. TimeSamplingPtr getTimeSampling() const { return getHeader().getTimeSampling(); } //! All properties have an object that owns them, and in order to //! ensure the object stays alive as long as the properties do, they //! retain a shared pointer to their object. virtual ObjectWriterPtr getObject() = 0; //! Most properties live in a compound property. (Except for //! the top-compound property in any object) //! This returns a pointer to the parent compound property. virtual CompoundPropertyWriterPtr getParent() = 0; //! Up-cast this base property to a ScalarProperty, if such an //! upcast is valid. This can be checked with the \ref isScalar() //! function. If the upcast is not valid, an empty pointer will //! be returned. This default implementation returns an empty //! pointer. virtual ScalarPropertyWriterPtr asScalarPtr(); //! Up-cast this base property to an ArrayProperty, if such an //! upcast is valid. This can be checked with the \ref isArray() //! function. If the upcast is not valid, an empty pointer will //! be returned. This default implementation returns an empty //! pointer. virtual ArrayPropertyWriterPtr asArrayPtr(); //! Up-cast this base property to a CompoundProperty, if such an //! upcast is valid. This can be checked with the \ref isCompound() //! function. If the upcast is not valid, an empty pointer will //! be returned. This default implementation returns an empty //! pointer. virtual CompoundPropertyWriterPtr asCompoundPtr(); }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/CMakeLists.txt000066400000000000000000000064221507001531700227540ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** LIST(APPEND CXX_FILES AbcCoreAbstract/Foundation.cpp AbcCoreAbstract/TimeSampling.cpp AbcCoreAbstract/TimeSamplingType.cpp AbcCoreAbstract/ArraySample.cpp AbcCoreAbstract/ReadArraySampleCache.cpp AbcCoreAbstract/ScalarSample.cpp AbcCoreAbstract/BasePropertyWriter.cpp AbcCoreAbstract/ScalarPropertyWriter.cpp AbcCoreAbstract/ArrayPropertyWriter.cpp AbcCoreAbstract/CompoundPropertyWriter.cpp AbcCoreAbstract/ObjectWriter.cpp AbcCoreAbstract/ArchiveWriter.cpp AbcCoreAbstract/BasePropertyReader.cpp AbcCoreAbstract/ScalarPropertyReader.cpp AbcCoreAbstract/ArrayPropertyReader.cpp AbcCoreAbstract/CompoundPropertyReader.cpp AbcCoreAbstract/ObjectReader.cpp AbcCoreAbstract/ArchiveReader.cpp ) SET(CXX_FILES "${CXX_FILES}" PARENT_SCOPE) INSTALL(FILES All.h ForwardDeclarations.h ArraySample.h ArraySampleKey.h ReadArraySampleCache.h ScalarSample.h DataType.h Foundation.h MetaData.h ObjectHeader.h PropertyHeader.h TimeSampling.h TimeSamplingType.h BasePropertyWriter.h ScalarPropertyWriter.h ArrayPropertyWriter.h CompoundPropertyWriter.h ObjectWriter.h ArchiveWriter.h BasePropertyReader.h ScalarPropertyReader.h ArrayPropertyReader.h CompoundPropertyReader.h ObjectReader.h ArchiveReader.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Alembic/AbcCoreAbstract ) IF (USE_TESTS) ADD_SUBDIRECTORY(Tests) ENDIF() alembic-1.8.9/lib/Alembic/AbcCoreAbstract/CompoundPropertyReader.cpp000066400000000000000000000116011507001531700253670ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** CompoundPropertyReader::~CompoundPropertyReader() { // Nothing } //-***************************************************************************** BasePropertyReaderPtr CompoundPropertyReader::getProperty( const std::string &iName ) { const PropertyHeader *header = getPropertyHeader( iName ); if ( !header ) { return BasePropertyReaderPtr(); } else { switch ( header->getPropertyType() ) { default: case kScalarProperty: return getScalarProperty( header->getName() ); case kArrayProperty: return getArrayProperty( header->getName() ); case kCompoundProperty: return getCompoundProperty( header->getName() ); } } } //-***************************************************************************** ScalarPropertyReaderPtr CompoundPropertyReader::getScalarProperty( size_t i ) { // This will throw if bad index. const PropertyHeader &header = getPropertyHeader( i ); if ( header.getPropertyType() != kScalarProperty ) { return ScalarPropertyReaderPtr(); } else { return getScalarProperty( header.getName() ); } } //-***************************************************************************** ArrayPropertyReaderPtr CompoundPropertyReader::getArrayProperty( size_t i ) { // This will throw if bad index. const PropertyHeader &header = getPropertyHeader( i ); if ( header.getPropertyType() != kArrayProperty ) { return ArrayPropertyReaderPtr(); } else { return getArrayProperty( header.getName() ); } } //-***************************************************************************** CompoundPropertyReaderPtr CompoundPropertyReader::getCompoundProperty( size_t i ) { // This will throw if bad index. const PropertyHeader &header = getPropertyHeader( i ); if ( header.getPropertyType() != kCompoundProperty ) { return CompoundPropertyReaderPtr(); } else { return getCompoundProperty( header.getName() ); } } //-***************************************************************************** BasePropertyReaderPtr CompoundPropertyReader::getProperty( size_t i ) { // This will throw if bad index. const PropertyHeader &header = getPropertyHeader( i ); switch ( header.getPropertyType() ) { default: case kScalarProperty: return getScalarProperty( header.getName() ); case kArrayProperty: return getArrayProperty( header.getName() ); case kCompoundProperty: return getCompoundProperty( header.getName() ); } } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/CompoundPropertyReader.h000066400000000000000000000130641507001531700250410ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_CompoundPropertyReader_h #define Alembic_AbcCoreAbstract_CompoundPropertyReader_h #include #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! A CompoundProperty is a group of other properties, possibly Simple //! or possibly Compound. Every object has at one of these. class ALEMBIC_EXPORT CompoundPropertyReader : public BasePropertyReader { public: //! Virtual destructor //! ... virtual ~CompoundPropertyReader(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! Returns the number of properties read from the file //! ... virtual size_t getNumProperties() = 0; //! Return the header of a property by index. //! This will throw an exception on out-of-range access. virtual const PropertyHeader & getPropertyHeader( size_t i ) = 0; //! Return the header of a property name. //! This will return a NULL pointer if no header by that name is found. virtual const PropertyHeader * getPropertyHeader( const std::string &iName ) = 0; //! Get a Scalar Property by name.. //! It will return an empty pointer if the property is not scalar or //! is not found. virtual ScalarPropertyReaderPtr getScalarProperty( const std::string &iName ) = 0; //! Get a Array Property by name.. //! It will return an empty pointer if the property is not array or //! is not found. virtual ArrayPropertyReaderPtr getArrayProperty( const std::string &iName ) = 0; //! Get a Compound Property by name.. //! It will return an empty pointer if the property is not compound or //! is not found. virtual CompoundPropertyReaderPtr getCompoundProperty( const std::string &iName ) = 0; //! Get a base property by name. //! That property can be safely upcast. //! This is a convenience function that uses getPropertyHeader and //! the various named "get" functions here. BasePropertyReaderPtr getProperty( const std::string &iName ); //! Get a Scalar Property by index. //! It will return an empty pointer if the property is not scalar or //! is not found. //! This is convenience function that uses the above functions //! to get the answer. ScalarPropertyReaderPtr getScalarProperty( size_t i ); //! Get a Array Property by index. //! It will return an empty pointer if the property is not array or //! is not found. //! This is convenience function that uses the above functions //! to get the answer. ArrayPropertyReaderPtr getArrayProperty( size_t i ); //! Get a Compound Property by index. //! It will return an empty pointer if the property is not compound or //! is not found. //! This is convenience function that uses the above functions //! to get the answer. CompoundPropertyReaderPtr getCompoundProperty( size_t i ); //! Get a base property by index. //! It is an error to call with out-of-range indices. //! This is a convenience function that uses getPropertyHeader and //! the various named "get" functions here. BasePropertyReaderPtr getProperty( size_t i ); }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/CompoundPropertyWriter.cpp000066400000000000000000000051461507001531700254500ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** CompoundPropertyWriter::~CompoundPropertyWriter() { // Nothing } //-***************************************************************************** BasePropertyWriterPtr CompoundPropertyWriter::getProperty( size_t i ) { const PropertyHeader &header = getPropertyHeader( i ); return getProperty( header.getName() ); } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/CompoundPropertyWriter.h000066400000000000000000000132061507001531700251110ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_CompoundPropertyWriter_h #define Alembic_AbcCoreAbstract_CompoundPropertyWriter_h #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! A CompoundProperty is a group of other properties, possibly Simple //! or possibly Compound. Every object has at one of these. class ALEMBIC_EXPORT CompoundPropertyWriter : public BasePropertyWriter { public: //! Virtual destructor //! ... virtual ~CompoundPropertyWriter(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! Returns the number of properties that have been created thus far. //! May change as more are created. virtual size_t getNumProperties() = 0; //! Return the header of a property that has already been added. //! Property is selected by index. //! This will throw an exception on out-of-range access. virtual const PropertyHeader & getPropertyHeader( size_t i ) = 0; //! Return the header of a property that has already been added, //! found by name. A typical use of this would be for an application //! that wants to incrementally add properties, and wishes to query //! whether a property of a given name has already been added, before //! attempting to add a new one. //! This will return NULL if no property of the given name has //! been added. virtual const PropertyHeader * getPropertyHeader( const std::string &iName ) = 0; //! It is an error to request for a property by index out of range. //! This returns a property that has ALREADY BEEN ADDED. //! This will throw an exception on out-of-range access. //! There is a possibility it could return a NULL pointer, if the //! added property has been closed (deleted). //! This is just a convenience function which calls getPropertyHeader //! and then getProperty. BasePropertyWriterPtr getProperty( size_t i ); //! Returns an ALREADY ADDED PROPERTY by name. If it can't find //! one by name, it returns an empty pointer. This can also happen //! if the property was added, but has been closed (deleted). virtual BasePropertyWriterPtr getProperty( const std::string & iName ) = 0; //! Create and return the requested scalar property. //! If a property already exists with the same name, throws //! an exception. An exception will also be thrown if the DataType, //! or time sampling index is illegal. virtual ScalarPropertyWriterPtr createScalarProperty( const std::string & iName, const MetaData & iMetaData, const DataType & iDataType, uint32_t iTimeSamplingIndex ) = 0; //! Create and return the requested array property. //! If a property already exists with the same name, throws. //! an exception. An exception will also be thrown if the DataType, //! or time sampling index is illegal. virtual ArrayPropertyWriterPtr createArrayProperty( const std::string & iName, const MetaData & iMetaData, const DataType & iDataType, uint32_t iTimeSamplingIndex ) = 0; //! Create and return the requested compound property. //! If a property already exists with the same name, throws //! an exception. virtual CompoundPropertyWriterPtr createCompoundProperty( const std::string & iName, const MetaData & iMetaData ) = 0; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/DataType.h000066400000000000000000000127151507001531700221020ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_DataType_h #define Alembic_AbcCoreAbstract_DataType_h #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! The DataType class is a description of how an element of a sample in a //! Scalar or an Array property is stored. It does not contain an interpretation //! this is left to the metadata of the properties themselves. class ALEMBIC_EXPORT DataType : Alembic::Util::totally_ordered { public: //! Default constructor //! Sets the DataType to an unknown DataType with extent 0. //! This is obviously an invalid storage description, and is used in //! cases where we need to indicated that a DataType could not be //! determined. DataType() : m_pod( kUnknownPOD ), m_extent( 0 ) {} //! Explicit constructor. //! Takes a pod and an extent. //! By default the extent is 1. //! For String and Wstring types, the extent _must_ be 1. explicit DataType( PlainOldDataType iPod, uint8_t iExtent = 1 ) : m_pod( iPod ), m_extent( iExtent ) {} //! Default copy constructor used. //! Default assignment operator used. //! Return the PlainOldDataType enum //! ... PlainOldDataType getPod() const { return m_pod; } //! Set the PlainOldDataType //! ... void setPod( PlainOldDataType iPod ) { m_pod = iPod; } //! Return the 8-bit extent //! ... uint8_t getExtent() const { return m_extent; } //! Set the 8-bit extent //! ... void setExtent( uint8_t iExtent ) { m_extent = iExtent; } //! Returns the number of bytes occupied by a single datum. (element) //! The assumption that each element has a fixed size in memory is a //! core assumption in Alembic. //! //! String DataTypes are a troublesome problem. A single string datum //! does not have a fixed number of bytes associated with it. So we //! are returning, here, the size of the std::string and std::wstring //! datatypes, respectively. size_t getNumBytes() const { return PODNumBytes( m_pod ) * ( size_t )m_extent; } //! Equality operator //! ... bool operator==( const DataType &b ) const { return ( ( m_pod == b.m_pod ) && ( m_extent == b.m_extent ) ); } //-************************************************************************* //! Returns whether one datatype is lexigraphically "less" than //! another - this has meaning only so that DataType instances can //! be meaningfully sorted. bool operator<( const DataType &b ) const { if ( m_pod < b.m_pod ) { return true; } else if ( m_pod > b.m_pod ) { return false; } else { return ( m_extent < b.m_extent ); } } private: //! An Enum indicating which PlainOldDataType is our //! super-storage-class. PlainOldDataType m_pod; //! An 8-bit extent indicating the cardinality of //! a single element of data. uint8_t m_extent; }; //-***************************************************************************** //! Outputs DataType to a std::ostream //! Makes use of PlainOldDataType's string conversion functions inline std::ostream &operator<<( std::ostream &ostr, const DataType &a ) { ostr << PODName( a.getPod() ); if ( a.getExtent() > 1 ) { ostr << "[" << ( size_t )a.getExtent() << "]"; } return ostr; } } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ForwardDeclarations.h000066400000000000000000000105631507001531700243230ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ForwardDeclarations_h #define Alembic_AbcCoreAbstract_ForwardDeclarations_h #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! Helper types forward declared. //! ... class TimeSampling; class ArraySample; //-***************************************************************************** //! Writer types forward declared. //! ... class ArchiveWriter; class ObjectWriter; class CompoundPropertyWriter; class ArrayPropertyWriter; class ScalarPropertyWriter; class BasePropertyWriter; //-***************************************************************************** //! Reader types forward declared. //! ... class ArchiveReader; class ObjectReader; class CompoundPropertyReader; class ArrayPropertyReader; class ScalarPropertyReader; class BasePropertyReader; //-***************************************************************************** //! Smart Ptrs to Helper types. //! The Ptr suffix in Alembic _ALWAYS_ refers to a shared_ptr of whatever //! class name precedes the Ptr suffix. typedef Alembic::Util::shared_ptr ArraySamplePtr; //-***************************************************************************** //! Smart Ptrs to Writers. typedef Alembic::Util::shared_ptr ArchiveWriterPtr; typedef Alembic::Util::shared_ptr ObjectWriterPtr; typedef Alembic::Util::shared_ptr CompoundPropertyWriterPtr; typedef Alembic::Util::shared_ptr ArrayPropertyWriterPtr; typedef Alembic::Util::shared_ptr ScalarPropertyWriterPtr; typedef Alembic::Util::shared_ptr BasePropertyWriterPtr; //-***************************************************************************** //! Smart Ptrs to Readers. typedef Alembic::Util::shared_ptr ArchiveReaderPtr; typedef Alembic::Util::shared_ptr ObjectReaderPtr; typedef Alembic::Util::shared_ptr CompoundPropertyReaderPtr; typedef Alembic::Util::shared_ptr ArrayPropertyReaderPtr; typedef Alembic::Util::shared_ptr ScalarPropertyReaderPtr; typedef Alembic::Util::shared_ptr BasePropertyReaderPtr; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/Foundation.cpp000066400000000000000000000057201507001531700230260ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { std::string GetLibraryVersionShort() { int32_t ver = ALEMBIC_LIBRARY_VERSION; std::ostringstream ostrm; ostrm << ( ver / 10000 ) << "." << ( ( ver / 100 ) - ( ( ver / 10000 ) * 100 ) ) << "." << ( ver - ( ( ver / 100 ) * 100 ) ); return ostrm.str(); } //-***************************************************************************** std::string GetLibraryVersion() { // "Alembic 1.0.0 (7/6/2011)" std::string alembicVersion = GetLibraryVersionShort(); std::ostringstream sversionString; sversionString << "Alembic " << alembicVersion << " (built " << __DATE__ << " " << __TIME__ ")"; return sversionString.str (); } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/Foundation.h000066400000000000000000000106441507001531700224740ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2014, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_Foundation_h #define Alembic_AbcCoreAbstract_Foundation_h #include #include #include #include #include #include #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { // Just pull the whole Util namespace in. This is safe. using namespace ::Alembic::Util; //! Index type //! Just being pedantic. typedef int64_t index_t; //! Returned by (to match index_t) #define INDEX_UNKNOWN 0x7fffffffffffffffLL //! Chrono type. //! This is used whenever time values are needed in the library. They are //! generally assumed to be seconds, but this does not need to be explicitly //! enforced by the API. typedef float64_t chrono_t; // Util/PlainOldDataType.h defines the enum PlainOldDataType #define kChrono_TPOD kFloat64POD //-***************************************************************************** // Alembic version information: // // Version information is expressed in these locations: // - CMakeLists.txt as PROJECT_VERSION // . Names used in messages and for install directory // - lib/Alembic/Util/Config.h as ALEMBIC_LIBRARY_VERSION // . An easy to compare numeric value. // - lib/Alembic/AbcCoreAbstract/Foundation.cpp // . Implementation of handy functions for reporting version info. //! Helper function which returns the version and date built in a string //! e.g. "Alembic 1.0.0 (built Jul 6 2011)" ALEMBIC_EXPORT std::string GetLibraryVersion(); //! Returns just the version number, as a string, of the Alembic library. //! e.g. "1.0.0" ALEMBIC_EXPORT std::string GetLibraryVersionShort(); //-***************************************************************************** //! Exception types borrowed from Alembic::Util. We should probably eventually //! create specific exception types. #define ABCA_THROW( TEXT ) ABC_THROW( TEXT ) //-***************************************************************************** #define ABCA_ASSERT( COND, TEXT ) \ do \ { \ if ( !( COND ) ) \ { \ ABCA_THROW( TEXT ); \ } \ } \ while( 0 ) } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/MetaData.h000066400000000000000000000266141507001531700220520ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_MetaData_h #define Alembic_AbcCoreAbstract_MetaData_h #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! The MetaData class lies at the core of Alembic's notion of //! "Object and Property Identity". It is a refinement of the idea of //! Protocol (for Objects) and Interpretation (for Properties) in OpenGTO. //! It is, essentially, an UNORDERED, UNIQUE DICTIONARY of strings. //! It turns itself into a regular string for serialization and deserialization. //! This is not a virtual class, nor is it intended to be used as a base //! for derivation. It is explicitly declared and implemented as part of //! the AbcCoreAbstract library. //! It is composed (not inherited) from \ref Alembic::Util::TokenMap. //! In order to not have duplicated (and possibly conflicting) policy //! implementation, we present this class here as a MOSTLY-WRITE-ONCE interface, //! with selective exception throwing behavior for failed writes. class MetaData { public: //-************************************************************************* // TYPEDEFS //-************************************************************************* //! Our internals are handled by a TokenMap, which we expose //! through these typedefs. typedef Alembic::Util::TokenMap token_map_type; //! Key type. //! Keys are unique within each MetaData instance. typedef token_map_type::key_type key_type; //! Data type. //! Data is associated with a key, with each key being unique. typedef token_map_type::data_type data_type; //! Value-type //! This is what the MetaData class "contains", when viewed //! as a standard container. typedef token_map_type::value_type value_type; //! Const reference type //! This is what the iterators dereference to. typedef token_map_type::const_reference const_reference; //! const_iterator typedef //! this dereferences to a const \ref value_type reference. typedef token_map_type::const_iterator const_iterator; //! const_reverse_iterator typedef //! this dereferences to a const \ref value_type instance. typedef token_map_type::const_reverse_iterator const_reverse_iterator; //-************************************************************************* // CONSTRUCTION //-************************************************************************* //! Default constructor creates an empty dictionary. //! ... MetaData() {} //! Copy constructor copies another MetaData. //! ... MetaData( const MetaData &iCopy ) : m_tokenMap( iCopy.m_tokenMap ) {} //! Assignment operator copies the contents of another //! MetaData instance. MetaData& operator=( const MetaData &iCopy ) { m_tokenMap = iCopy.m_tokenMap; return *this; } //-************************************************************************* // SERIALIZATION/DESERIALIZATION //-************************************************************************* //! Deserialization will replace the contents of this class with the //! parsed contents of a string. It will just clear the contents first. //! It will throw an exception if the string is mal-formed. //! \internal For library implementation internal use. void deserialize( const std::string &iFrom ) { m_tokenMap.clear(); m_tokenMap.setUnique( iFrom, ';', '=', true ); } //! Serialization will convert the contents of this MetaData into a //! single string. //! \internal For library implementation internal use. std::string serialize() const { return m_tokenMap.get( ';', '=', true ); } //-************************************************************************* // SIZE //-************************************************************************* size_t size() const { return m_tokenMap.size(); } //-************************************************************************* // ITERATION //-************************************************************************* //! Returns a \ref const_iterator corresponding to the beginning of the //! MetaData or the end of the MetaData if empty. const_iterator begin() const { return m_tokenMap.begin(); } //! Returns a \ref const_iterator corresponding to the end of the //! MetaData. const_iterator end() const { return m_tokenMap.end(); } //! Returns a \ref const_reverse_iterator corresponding to the beginning //! of the MetaData or the end of the MetaData if empty. const_reverse_iterator rbegin() const { return m_tokenMap.rbegin(); } //! Returns an \ref const_reverse_iterator corresponding to the end //! of the MetaData. const_reverse_iterator rend() const { return m_tokenMap.rend(); } //-************************************************************************* // ACCESS/ASSIGNMENT //-************************************************************************* //! set lets you set a key/data pair. //! This will silently overwrite an existing value. void set( const std::string &iKey, const std::string &iData ) { m_tokenMap.setValue( iKey, iData ); } //! setUnique lets you set a key/data pair, //! but throws an exception if you attempt to change the value //! of an existing field. It is fine if you set the same value. //! \remarks Not the most efficient implementation at the moment. void setUnique( const std::string &iKey, const std::string &iData ) { std::string found = m_tokenMap.value( iKey ); if ( found == "" ) { m_tokenMap.setValue( iKey, iData ); } else if ( found != iData ) { ABCA_THROW( "Key: " << iKey << " already exists in MetaData" ); } } //! get returns the value, or an empty string if it is not set. //! ... std::string get( const std::string &iKey ) const { return m_tokenMap.value( iKey ); } //! getRequired returns the value, and throws an exception if it is //! not found. std::string getRequired( const std::string &iKey ) const { std::string ret = m_tokenMap.value( iKey ); if ( ret == "" ) { ABCA_THROW( "Key: " << iKey << " did not exist in MetaData" ); } return ret; } //! append appends the given MetaData to this class. Duplicates are //! overwritten. void append( const MetaData &iMetaData ) { for ( const_iterator iter = iMetaData.begin(); iter != iMetaData.end(); ++iter ) { set( (*iter).first, (*iter).second ); } } //! append appends the given MetaData to this class. Duplicate keys //! are ignored, and the original value remains untouched void appendOnlyUnique( const MetaData &iMetaData ) { for ( const_iterator iter = iMetaData.begin(); iter != iMetaData.end(); ++iter ) { if ( !m_tokenMap.tokenExists( (*iter).first ) ) { set( (*iter).first, (*iter).second ); } } } //! append appends the given MetaData to this class. Duplicate values //! will cause an exception to be thrown. void appendUnique( const MetaData &iMetaData ) { for ( const_iterator iter = iMetaData.begin(); iter != iMetaData.end(); ++iter ) { setUnique( (*iter).first, (*iter).second ); } } //-************************************************************************* // MATCHING // Simple matching for now, we'll save regex stuff for later. //-************************************************************************* //! The matches function returns true if each of the fields in the passed //! iMetaData are found in this instance and have the same values. //! it returns false otherwise. //! This is not the same as "equals", because this MetaData may contain //! fields that are not included in the passed iMetaData. //! This should be the default "matching" function. bool matches( const MetaData &iMetaData ) const { for ( const_iterator iter = iMetaData.begin(); iter != iMetaData.end(); ++iter ) { if ( get( (*iter).first ) != (*iter).second ) { return false; } } return true; } //! The matchesExisting function returns true if, for each of the fields //! in the passed iMetaData, we have either no entry, or the same entry. bool matchesOverlap( const MetaData &iMetaData ) const { for ( const_iterator iter = iMetaData.begin(); iter != iMetaData.end(); ++iter ) { std::string found = get( (*iter).first ); if ( found != "" && found != (*iter).second ) { return false; } } return true; } //! the matchesExactly function returns true if we're exactly equal in //! every field. This is a rarely useful concept with MetaData. //! It is for this reason that we explicitly do not overload the == operator. bool matchesExactly( const MetaData &iMetaData ) const { return m_tokenMap.exactMatch( iMetaData.m_tokenMap ); } private: Alembic::Util::TokenMap m_tokenMap; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ObjectHeader.h000066400000000000000000000077421507001531700227120ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ObjectHeader_h #define Alembic_AbcCoreAbstract_ObjectHeader_h #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! The ObjectHeader is a collection of MetaData which helps define a //! Property. It also acts as a key for getting an instance of a property //! from a CompoundProperty. class ObjectHeader { public: //! Default constructor creates an unspecified object header. //! ... ObjectHeader() : m_name() , m_fullName() , m_metaData() {} //! Explicit constructor, ignoring full name. //! ... ObjectHeader( const std::string &iName, const MetaData &iMetaData ) : m_name( iName ) , m_fullName( "" ) , m_metaData( iMetaData ) {} //! Explicit constructor with full name. //! ... ObjectHeader( const std::string &iName, const std::string &iFullName, const MetaData &iMetaData ) : m_name( iName ) , m_fullName( iFullName ) , m_metaData( iMetaData ) {} //! Default Copy constructor //! Default Assignment operator //! All objects have a name, which is unique amongst its siblings. //! ... const std::string &getName() const { return m_name; } void setName ( const std::string &iName ) { m_name = iName; } //! All objects have a full name, which is unique in the whole file. //! ... const std::string &getFullName() const { return m_fullName; } void setFullName( const std::string &iFullName ) { m_fullName = iFullName; } //! All objects have metadata. //! It is manipulated directly. const MetaData &getMetaData() const { return m_metaData; } MetaData &getMetaData() { return m_metaData; } private: std::string m_name; std::string m_fullName; MetaData m_metaData; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ObjectReader.cpp000066400000000000000000000050361507001531700232510ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** ObjectReader::~ObjectReader() { // Nothing } //-***************************************************************************** bool ObjectReader::getPropertiesHash( Util::Digest & oDigest ) { return false; } //-***************************************************************************** bool ObjectReader::getChildrenHash( Util::Digest & oDigest ) { return false; } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ObjectReader.h000066400000000000000000000201711507001531700227130ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2013, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ObjectReader_h #define Alembic_AbcCoreAbstract_ObjectReader_h #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! An Object consists of a list of children objects, which may be empty, //! and a single compound property which is the root of any properties //! which the object may contain. //! Objects have MetaData, which is identical to the MetaData of the root //! Compound Property. class ALEMBIC_EXPORT ObjectReader : private Alembic::Util::noncopyable { public: //! Virtual destructor //! ... virtual ~ObjectReader(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! All objects have a header, which contains all the MetaData that was //! specified upon their creation. //! This function returns a constant reference to that Header. virtual const ObjectHeader &getHeader() const = 0; //! All objects have a name. This name is unique amongst their siblings //! Returned by reference, since it is guaranteed to exist and be //! unchanging. //! This is a convenience function which returns the header's name. const std::string &getName() const { return getHeader().getName(); } //! The full name of an object is the complete path name all the way //! to the root object of the archive. It is guaranteed to be fully //! unique within the entire archive. //! This is a convenience function which returns the header's full name. const std::string &getFullName() const { return getHeader().getFullName(); } //! All objects have metadata. This metadata is identical to the //! Metadata of the top level compoundProperty "properties". //! Because the metadata must exist and be initialized in order to //! bootstrap the object, it is guaranteed to exist and is returned //! by reference. //! This is a convenience function which returns the header's MetaData. const MetaData &getMetaData() const { return getHeader().getMetaData(); } //! All objects have a shared link to the root. This may seem //! wasteful, but it is essential in order to allow for the flexible, //! reference-counted autonomy of the reader objects. Alembic //! allows you to keep references to readers wherever you want, //! without requiring you to keep track of (or store) the parental //! hierarchy directly. In order to make this possible, we have //! the ability to walk upwards. This may be stored as a direct //! link, or retrieved by walking up the parent chain, which is //! a feature of the individual implementations. (it might not be //! cheap, basically). //! In order to prevent shared_ptr cycles, it is important //! that objects only store their children via weak ptrs. virtual ArchiveReaderPtr getArchive() = 0; //! All objects have a shared link to their parent. This may seem //! wasteful, but it is essential in order to allow for the flexible, //! reference-counted autonomy of the reader objects. Alembic //! allows you to keep references to readers wherever you want, //! without requiring you to keep track of (or store) the parental //! hierarchy directly. In order to make this possible, we have //! the ability to walk upwards. //! In order to prevent shared_ptr cycles, it is important //! that objects only store their children via weak ptrs. virtual ObjectReaderPtr getParent() = 0; //! All objects have one and only one compound property which //! is the root for any properties which are associated with this object. //! If no properties were written to the object, this may return an //! empty pointer. virtual CompoundPropertyReaderPtr getProperties() = 0; //-************************************************************************* // Children! //-************************************************************************* //! Returns the number of objects that are contained as children. //! Objects do not have to have children, this may return zero. virtual size_t getNumChildren() = 0; //! Return the header of an object by index. //! This will throw an exception on out-of-range access. virtual const ObjectHeader & getChildHeader( size_t i ) = 0; //! Return the header of an object by name. //! This will return a NULL pointer if no header by that name is found. virtual const ObjectHeader * getChildHeader( const std::string &iName ) = 0; //! Get a child object by name. //! This is a convenience function that uses getChildHeader and //! the various named "get" functions here. virtual ObjectReaderPtr getChild( const std::string &iName ) = 0; //! Get a child object by index. //! It is an error to call with out-of-range indices. //! This is a convenience function that uses getChildHeader and //! the various named "get" functions here. virtual ObjectReaderPtr getChild( size_t i ) = 0; //-************************************************************************* // Hierarchical hash stuff //-************************************************************************* //! If an aggregated properties hash exists fill oDigest with it and //! return true, if it doesn't exist return false virtual bool getPropertiesHash( Util::Digest & oDigest ); //! If an aggregated child objects hash exists fill oDigest with it and //! return true, if it doesn't exist return false virtual bool getChildrenHash( Util::Digest & oDigest ); //-************************************************************************* // YUP //-************************************************************************* //! Returns shared pointer to myself. //! This is non-virtual virtual ObjectReaderPtr asObjectPtr() = 0; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ObjectWriter.cpp000066400000000000000000000047731507001531700233320ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** ObjectWriter::~ObjectWriter() { // Nothing // std::cout << "ObjectWriter::~ObjectWriter() " << std::endl; } //-***************************************************************************** ObjectWriterPtr ObjectWriter::getChild( size_t i ) { const ObjectHeader &ohead = getChildHeader( i ); return getChild( ohead.getName() ); } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ObjectWriter.h000066400000000000000000000215651507001531700227750ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ObjectWriter_h #define Alembic_AbcCoreAbstract_ObjectWriter_h #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! An Object consists of a list of children objects, which may be empty, //! and a single compound property which is the root of any properties //! which the object may contain. //! Objects have MetaData, which is identical to the MetaData of the root //! Compound Property. class ALEMBIC_EXPORT ObjectWriter : private Alembic::Util::noncopyable { public: //! Virtual destructor //! ... virtual ~ObjectWriter(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! All objects are created from an ObjectHeader, which contains their //! name, their full name, and their MetaData. This returns //! a const reference to the ObjectHeader which was given upon //! creation. virtual const ObjectHeader & getHeader() const = 0; //! All objects have a name. This name is unique amongst their siblings //! Returned by reference, since it is guaranteed to exist and be //! unchanging. This is the name that was given when the object was //! created. const std::string &getName() const { return getHeader().getName(); } //! The full name of an object is the complete path name all the way //! to the root object of the archive. It is guaranteed to be fully //! unique within the entire archive. const std::string &getFullName() const { return getHeader().getFullName(); } //! All objects have metadata. This metadata is identical to the //! Metadata of the top level compoundProperty "properties". //! Because the metadata must exist and be initialized in order to //! bootstrap the object, it is guaranteed to exist and is returned //! by reference. While MetaData was required to create the object, //! additional MetaData may be appended during the writing of the //! object. This returns the accumulated MetaData, which may change //! as writing occurs. The reference will remain valid, but the //! MetaData it points to may change over time. const MetaData &getMetaData() const { return getHeader().getMetaData(); } //! All objects have a shared link to the root. This may seem //! wasteful, but it is essential in order to allow for the flexible, //! reference-counted autonomy of the writer objects. Alembic //! allows you to keep references to writers wherever you want, //! without requiring you to keep track of (or store) the parental //! hierarchy directly. In order to make this possible, we have //! the ability to walk upwards. This may be stored as a direct //! link, or retrieved by walking up the parent chain, which is //! a feature of the individual implementations. (it might not be //! cheap, basically). //! In order to prevent shared_ptr cycles, it is important //! that objects only store their children via weak ptrs. virtual ArchiveWriterPtr getArchive() = 0; //! All objects have a shared link to their parent. This may seem //! wasteful, but it is essential in order to allow for the flexible, //! reference-counted autonomy of the writer objects. Alembic //! allows you to keep references to writers wherever you want, //! without requiring you to keep track of (or store) the parental //! hierarchy directly. In order to make this possible, we have //! the ability to walk upwards. //! In order to prevent shared_ptr cycles, it is important //! that objects only store their children via weak ptrs. virtual ObjectWriterPtr getParent() = 0; //! All objects have a single compound property which is the //! root for any properties which are associated with this object. //! Guaranteed to exist, even if the compound property itself is //! empty. This may change as properties are added. virtual CompoundPropertyWriterPtr getProperties() = 0; //-************************************************************************* // CHILDREN //-************************************************************************* //! Returns the number of objects that are contained as children. //! this number may increase (but not decrease) as objects are //! created. This is the number of children object writers that //! have ALREADY BEEN ADDED. It may increase. virtual size_t getNumChildren() = 0; //! Returns the header of an object that has already been added. //! Object is selected by index. //! This will throw an exception on out-of-range access. virtual const ObjectHeader & getChildHeader( size_t i ) = 0; //! Returns the header of an object that has already been added, //! by name. //! This will return NULL pointer if no header by that name is found. //! Even if the object assosciated with this header is no longer //! existing, the header will be non-null if any such object //! had been created. This is a mechanism for testing if something //! has already been made. virtual const ObjectHeader * getChildHeader( const std::string &iName ) = 0; //! Returns a pointer to an object writer at the given index, //! that has ALREADY BEEN ADDED. It is an error to request a child //! with an out of range index, and an exception will be thrown. //! In a strange case, //! this will return an empty pointer if the writer has been //! added in the past, but was closed (deleted). There is really //! no distinction between an empty weak pointer and a weak pointer //! to an expired object, so we simply return an empty pointer //! if the object had been created but no longer exists. //! This is just a convenience function that uses getChildHeader //! and getChild( name ); ObjectWriterPtr getChild( size_t i ); //! Returns a pointer to an object writer of the given name iName, //! for an object that has ALREADY BEEN ADDED. This will return //! an empty pointer if no object of the given name has been added. virtual ObjectWriterPtr getChild( const std::string &iName ) = 0; //! Create an object with given header. //! the header's "fullName" will be ignored and set by the parent object. //! If an object with the given name already exists, an exception will //! be thrown, as this is a programming error. virtual ObjectWriterPtr createChild( const ObjectHeader &iHeader ) = 0; //! Returns shared pointer to myself. //! Sometimes this may be a spoofed ptr. virtual ObjectWriterPtr asObjectPtr() = 0; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/PropertyHeader.h000066400000000000000000000174431507001531700233270ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_PropertyHeader_h #define Alembic_AbcCoreAbstract_PropertyHeader_h #include #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! In Alembic, Objects may have three distinct types of abstract properties. //! Any fancy type-specific properties are ultimately and instance of one //! of these three types of properties, identified here by an enum. //! "Simple" properties are simply "non-compound" properties - //! the SimpleProperty classes are simply common base classes for //! Scalar and Array Properties. enum PropertyType { //! Compound Properties are groups of other properties, with their own //! unique name and set of MetaData. All objects have a single root //! compound property as the base of their property description. kCompoundProperty = 0, //! Scalar Properties represent Rank-0 properties, which contain a //! single element value for any given time sample. kScalarProperty = 1, //! Array Properties represent Rank-N properties, which contain an //! array of values for any given time sample. Array properties may have //! any rank of 1 or higher, but will most often be ranks 1, 2, 3. kArrayProperty = 2 }; //-***************************************************************************** //! The PropertyHeader is a collection of MetaData which helps define a //! Property. It also acts as a key for getting an instance of a property //! from a CompoundProperty. class PropertyHeader { public: //! Default constructor creates an invalid property. //! The propertyType is set to Scalar, but the dataType will be set //! to its default value of kUnknownPOD[1] PropertyHeader() : m_name(), m_propertyType( kScalarProperty ), m_metaData(), m_dataType(), m_timeSampling() {} //! Construct a compound property header. //! Just give a name and metadata, the rest is redundant or unused. explicit PropertyHeader( const std::string &iName, const MetaData &iMetaData ) : m_name( iName ), m_propertyType( kCompoundProperty ), m_metaData( iMetaData ), m_dataType(), m_timeSampling() {} //! Construct a simple property header. //! Use this for array or scalar properties. PropertyHeader( const std::string &iName, PropertyType iPropType, const MetaData &iMetaData, const DataType &iDataType, const TimeSamplingPtr & iTsamp ) : m_name( iName ), m_propertyType( iPropType ), m_metaData( iMetaData ), m_dataType( iDataType ), m_timeSampling( iTsamp ) {} //! Copy constructor //! ... PropertyHeader( const PropertyHeader &iCopy ) : m_name( iCopy.m_name ), m_propertyType( iCopy.m_propertyType ), m_metaData( iCopy.m_metaData ), m_dataType( iCopy.m_dataType ), m_timeSampling( iCopy.m_timeSampling ) {} //! Assignment operator //! ... PropertyHeader& operator=( const PropertyHeader &iCopy ) { m_name = iCopy.m_name; m_propertyType = iCopy.m_propertyType; m_metaData = iCopy.m_metaData; m_dataType = iCopy.m_dataType; m_timeSampling = iCopy.m_timeSampling; return *this; } //! All properties have a name, which is unique amongst its siblings. //! ... const std::string &getName() const { return m_name; } void setName( const std::string &iName ) { m_name = iName; } //! All properties have a type, which is the enum defined above. //! ... PropertyType getPropertyType() const { return m_propertyType; } void setPropertyType( PropertyType iPtyp ) { m_propertyType = iPtyp; } //! Convenience to return whether the property is scalar. //! Same as getPropertyType() == kScalarProperty bool isScalar() const { return m_propertyType == kScalarProperty; } //! Convenience to return whether the property is array. //! Same as getPropertyType() == kArrayProperty bool isArray() const { return m_propertyType == kArrayProperty; } //! Convenience to return whether the property is compound. //! Same as getPropertyType() == kCompoundProperty bool isCompound() const { return m_propertyType == kCompoundProperty; } //! Convenience to return whether the property is simple (non-compound) //! Same as getPropertyType() != kCompoundProperty bool isSimple() const { return !isCompound(); } //! All properties have metadata. //! ... const MetaData &getMetaData() const { return m_metaData; } void setMetaData( const MetaData &iMetaData ) { m_metaData = iMetaData; } //! Non-compound properties have a data type. //! If this is called for a Compound Property (basically, one which //! returns kCompoundProperty from getType() above) //! it will throw an exception. const DataType &getDataType() const { return m_dataType; } void setDataType( const DataType &iDataType ) { m_dataType = iDataType; } //! Non-compound properties have time sampling //! If this is called for a Compound Property (basically, one which //! returns kCompoundProperty from getType() above) //! it will throw an exception. TimeSamplingPtr getTimeSampling() const { return m_timeSampling; } void setTimeSampling( const TimeSamplingPtr &iTsamp ) { m_timeSampling = iTsamp; } private: std::string m_name; PropertyType m_propertyType; MetaData m_metaData; DataType m_dataType; TimeSamplingPtr m_timeSampling; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ReadArraySampleCache.cpp000066400000000000000000000043541507001531700246620ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** ReadArraySampleCache::~ReadArraySampleCache() { // Nothing! } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ReadArraySampleCache.h000066400000000000000000000132501507001531700243220ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ReadArraySampleCache_h #define Alembic_AbcCoreAbstract_ReadArraySampleCache_h #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! A ReadArraySampleID is a bundle that contains a pointer to the //! \ref ArraySample itself, along with the sample's key. class ReadArraySampleID { public: //! By convention, we define the typedef this_type. This //! is used by the unspecified-bool-type cast below. typedef ReadArraySampleID this_type; //! Default constructor creates empty ID //! ... ReadArraySampleID() {} //! Explicit constructor creates ID with key and sample ReadArraySampleID( const ArraySample::Key &iSampleKey, ArraySamplePtr iSample ) : m_sampleKey( iSampleKey ), m_sample( iSample ) {} //! Default copy constructor //! Default assignment operator. //! Return the sample key //! ... const ArraySample::Key &getKey() const { return m_sampleKey; } //! Return the sample itself. //! ... ArraySamplePtr getSample() const { return m_sample; } //! Return whether or not this read sample is valid //! ... bool valid() const { return ( m_sample && m_sample->valid() ); } //! Unspecified bool type cast //! ... ALEMBIC_OPERATOR_BOOL( valid() ); private: ArraySample::Key m_sampleKey; ArraySamplePtr m_sample; }; //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** // READ ARRAY SAMPLE CACHE //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** //! Alembic caches array samples based on a Murmur3 128bit checksum key. //! This is an abstract interface to these caches, which can be implemented //! in any number of ways. class ALEMBIC_EXPORT ReadArraySampleCache : private Alembic::Util::noncopyable , public Alembic::Util::enable_shared_from_this { public: //! Virtual destructor //! ... virtual ~ReadArraySampleCache(); //! If it finds the entry, return a valid pointer to it which //! is expected to lock the entry in the cache until the pointer //! is dereferenced. virtual ReadArraySampleID find( const ArraySample::Key &iKey ) = 0; //! Store an entry given an explicit set of storage. //! The magnificent flexibility of the shared_ptr class makes //! it possible for an ArraySamplePtr to contain its own destructor //! as a custom deleter, and thus we can use ArraySamplePtrs for //! both reference and ownership, depending on the deleter. //! In this case, it is assumed that iSamp represents //! "owned" data, rather than a reference. The data will not //! be copied, but rather this sample will be stored directly //! using the passed shared_ptr. virtual ReadArraySampleID store( const ArraySample::Key &iKey, ArraySamplePtr iSamp ) = 0; }; //-***************************************************************************** typedef Alembic::Util::shared_ptr ReadArraySampleCachePtr; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ScalarPropertyReader.cpp000066400000000000000000000043521507001531700250150ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** ScalarPropertyReader::~ScalarPropertyReader() { // Nothing } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ScalarPropertyReader.h000066400000000000000000000122351507001531700244610ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ScalarPropertyReader_h #define Alembic_AbcCoreAbstract_ScalarPropertyReader_h #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! A Scalar Property is a Rank 0 property which has a single value for each //! sample. This is distinguished from an Array Property, which has a //! variable number of elements per sample, and requires more sophisticated //! resource management. class ALEMBIC_EXPORT ScalarPropertyReader : public BasePropertyReader { public: //! Virtual destructor //! ... virtual ~ScalarPropertyReader(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! Return the number of samples contained in the property. //! This can be any number, including zero. //! This returns the number of samples that were written, independently //! of whether or not they were constant. Implementations may (and should) //! choose to condense identical samples. virtual size_t getNumSamples() = 0; //! Ask if we're constant - no change in value amongst samples, //! regardless of the time sampling. virtual bool isConstant() = 0; //! Returns the single sample value for the requested sample //! by reference. Out-of-range indices will cause an //! exception to be thrown. //! It will copy the scalar value directly into the memory location //! specified by iIntoLocation //! //! In all cases EXCEPT String and Wstring, the DataType for this //! property can be used to determine the size of the memory buffer //! which iIntoLocation must point to. In the case of String and Wstring, //! iIntoLocation should be ( void * )&std::string and //! ( void * )&std::wstring, respectively. //! //! This is one of the only places where we break from POD types at //! the base, and we're making an explicit decision to use std::string //! and std::wstring as core language-level primitives. virtual void getSample( index_t iSample, void *iIntoLocation ) = 0; //! Find the largest valid index that has a time less than or equal //! to the given time. Invalid to call this with zero samples. //! If the minimum sample time is greater than iTime, index //! 0 will be returned. virtual std::pair getFloorIndex( chrono_t iTime ) = 0; //! Find the smallest valid index that has a time greater //! than the given time. Invalid to call this with zero samples. //! If the maximum sample time is less than iTime, index //! numSamples-1 will be returned. virtual std::pair getCeilIndex( chrono_t iTime ) = 0; //! Find the valid index with the closest time to the given //! time. Invalid to call this with zero samples. virtual std::pair getNearIndex( chrono_t iTime ) = 0; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ScalarPropertyWriter.cpp000066400000000000000000000043521507001531700250670ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** ScalarPropertyWriter::~ScalarPropertyWriter() { // Nothing } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ScalarPropertyWriter.h000066400000000000000000000102731507001531700245330ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ScalarPropertyWriter_h #define Alembic_AbcCoreAbstract_ScalarPropertyWriter_h #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! A Scalar Property is a Rank 0 property which has a single value for each //! sample. This is distinguished from an Array Property, which has a //! variable number of elements per sample, and requires more sophisticated //! resource management. class ALEMBIC_EXPORT ScalarPropertyWriter : public BasePropertyWriter { public: //! Virtual destructor //! ... virtual ~ScalarPropertyWriter(); //-************************************************************************* // NEW FUNCTIONS //-************************************************************************* //! Sets a sample. //! //! For specifying the sample, this takes a void pointer which //! points to the beginning of the memory corresponding to the scalar. //! //! For String and Wstring, the const void *iSamp is assumed to be //! static_castable to const std::string * and const std::wstring *, //! respectively. //! //! The data passed into this function will be used or copied locally //! by this function, and need not live (in the calling context) //! outside the return scope of this function call. virtual void setSample( const void *iSamp ) = 0; //! Simply copies the previously written sample's value. //! This is an important feature. virtual void setFromPreviousSample() = 0; //! Return the number of samples that have been written so far. //! This changes as samples are written. virtual size_t getNumSamples() = 0; //! Changes the TimeSampling used by this property. //! If the TimeSampling is changed to Acyclic and the number of samples //! currently set is more than the number of times provided in the Acyclic //! TimeSampling, an exception will be thrown. virtual void setTimeSamplingIndex( uint32_t iIndex ) = 0; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ScalarSample.cpp000066400000000000000000000164451507001531700232750ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** template static inline bool equalWithRelAbsError( const T &iA, const T &iB, double iEpsilon ) { return iA == iB; } //-***************************************************************************** template <> inline bool equalWithRelAbsError( const float16_t &iA, const float16_t &iB, double iEpsilon ) { return fabs( ( double )( iA - iB ) ) < iEpsilon; } //-***************************************************************************** template <> inline bool equalWithRelAbsError( const float32_t &iA, const float32_t &iB, double iEpsilon ) { return fabs( ( double )( iA - iB ) ) < iEpsilon; } //-***************************************************************************** template <> inline bool equalWithRelAbsError( const float64_t &iA, const float64_t &iB, double iEpsilon ) { return fabs( ( double )( iA - iB ) ) < iEpsilon; } //-***************************************************************************** template class TypedScalarSampleData : public ScalarSample::Data { public: TypedScalarSampleData( size_t N ) : m_data( N ) { for ( size_t i = 0; i < N; ++i ) { m_data[i] = PODTraitsFromType::default_value(); } } virtual void setToDefault() { for ( size_t i = 0, N = m_data.size(); i < N; ++i ) { m_data[i] = PODTraitsFromType::default_value(); } } // THIS IS NOT MULTITHREAD SAFE, but currently is only // used during write operations. virtual void copyFrom( const void *iData ) { const T *iDataT = reinterpret_cast( iData ); for ( size_t i = 0, N = m_data.size(); i < N; ++i ) { m_data[i] = iDataT[i]; } } virtual bool equalTo( const void *iData ) const { const T *iDataT = reinterpret_cast( iData ); for ( size_t i = 0, N = m_data.size(); i < N; ++i ) { if ( m_data[i] != iDataT[i] ) { return false; } } return true; } virtual bool equalEpsilon( const void *iData, double iEpsilon ) const { const T *iDataT = reinterpret_cast( iData ); for ( size_t i = 0, N = m_data.size(); i < N; ++i ) { if ( !equalWithRelAbsError( m_data[i], iDataT[i], iEpsilon ) ) { return false; } } return true; } virtual bool lessThan( const void *iData ) const { const T *iDataT = reinterpret_cast( iData ); for ( size_t i = 0, N = m_data.size(); i < N; ++i ) { if ( m_data[i] < iDataT[i] ) { return true; } else if ( m_data[i] > iDataT[i] ) { return false; } } return false; } virtual const void *getData() const { return reinterpret_cast( &m_data.front() ); } protected: std::vector m_data; }; //-***************************************************************************** //-***************************************************************************** //-***************************************************************************** ScalarSample::ScalarSample( const DataType &iDataType ) : m_dataType( iDataType ) { size_t N = m_dataType.getExtent(); ABCA_ASSERT( m_dataType.getPod() != kUnknownPOD && N > 0, "Degenerate data type in scalar sample" ); switch ( m_dataType.getPod() ) { case kBooleanPOD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kUint8POD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kInt8POD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kUint16POD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kInt16POD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kUint32POD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kInt32POD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kUint64POD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kInt64POD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kFloat16POD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kFloat32POD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kFloat64POD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kStringPOD: m_data.reset( new TypedScalarSampleData( N ) ); break; case kWstringPOD: m_data.reset( new TypedScalarSampleData( N ) ); break; default: ABCA_THROW( "Unknown datatype in ScalarSample: " << m_dataType ); break; } } } // End namespace ALEMBIC_VERSION_NS } // End namespace AbcCoreAbstract } // End namespace Alembic alembic-1.8.9/lib/Alembic/AbcCoreAbstract/ScalarSample.h000066400000000000000000000161631507001531700227370ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks, Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_ScalarSample_h #define Alembic_AbcCoreAbstract_ScalarSample_h #include #include #include namespace Alembic { namespace AbcCoreAbstract { namespace ALEMBIC_VERSION_NS { //-***************************************************************************** //! ScalarSample is purely a helper class for implementations. //! It is not a required object of exchange within Alembic, and you wouldn't //! want this to be the carrier of data with scalars because you'd be //! carrying around the extra 2 bytes of "DataType" data every time you //! passed data, which is wasteful and unnecessary. //! //! However, since the Scalar Readers and Writers will always be obligated //! to compare samples to previously written samples and copy sample values, //! this class will be helpful in that regard. //! //! Plus - and this is just a hunch - I suspect that as Alembic evolves, //! there will be a need for this extra bit of encapsulation at the abstract //! level, which is why I'm putting it here. class ALEMBIC_EXPORT ScalarSample : public Alembic::Util::totally_ordered { public: //-************************************************************************* // Data //-************************************************************************* class Data { public: virtual ~Data() {} virtual void setToDefault() = 0; virtual void copyFrom( const void *iData ) = 0; virtual bool equalTo( const void *iData ) const = 0; virtual bool equalEpsilon( const void *iData, double iEpsilon ) const = 0; virtual bool lessThan( const void *iData ) const = 0; virtual const void *getData() const = 0; }; //! Construct from given data type and data. Data will be //! copied. If given data is NULL, internal data will be //! set to default value. explicit ScalarSample( const DataType &iDataType ); //! Assignment to just data. //! Will assume data is of the same type as described //! internally by our data type. //! is invalid to set to NULL here. void copyFrom( const void *iData ) { m_data->copyFrom( iData ); } //-************************************************************************* // Data Access //-************************************************************************* //! Returns the datatype. //! ... const DataType &getDataType() const { return m_dataType; } //! Returns the memory address corresponding to the data //! ... const void *getData() const { return m_data->getData(); } //-************************************************************************* // Comparison and Equality //-************************************************************************* //! Assuming the passed memory address points to data of the //! same type as us, are they equal? An element-by-element //! comparison is done. bool operator==( const void *iRhs ) const { return m_data->equalTo( iRhs ); } //! Are the data types exactly equal? //! This will do an element-by-element comparison. bool operator==( const ScalarSample &iRhs ) const { return ( iRhs.getDataType() == m_dataType ) && m_data->equalTo( iRhs.getData() ); } //! Are the data types equal with some precision. This only applies //! to floating point types, but will just ignore the relAbsError //! for the non-floating-point types. bool equalWithRelAbsError( const void *iRhs, double iRelAbsError ) const { return m_data->equalEpsilon( iRhs, iRelAbsError ); } //! Same as precision-bound equality operator above. //! ... bool equalWithRelAbsError( const ScalarSample &iRhs, double iRelAbsError ) const { return ( iRhs.getDataType() == m_dataType ) && m_data->equalEpsilon( iRhs.getData(), iRelAbsError ); } //! Sorting operator. Compares element by element, with //! first elements having precedence over later ones. bool operator<( const void *iRhs ) const { return m_data->lessThan( iRhs ); } //! Sorting operator. Compares element by element, with //! first elements having precedence over later ones. bool operator<( const ScalarSample &iRhs ) const { if ( m_dataType < iRhs.getDataType() ) { return true; } else if ( m_dataType > iRhs.getDataType() ) { return false; } else { return m_data->lessThan( iRhs.getData() ); } } //-************************************************************************* // Useful functions //-************************************************************************* //! Sets to to default values for whichever POD types are contained. //! ... void setToDefault() { m_data->setToDefault(); } private: DataType m_dataType; Alembic::Util::unique_ptr m_data; }; } // End namespace ALEMBIC_VERSION_NS using namespace ALEMBIC_VERSION_NS; } // End namespace AbcCoreAbstract } // End namespace Alembic #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/Tests/000077500000000000000000000000001507001531700213125ustar00rootroot00000000000000alembic-1.8.9/lib/Alembic/AbcCoreAbstract/Tests/Assert.h000066400000000000000000000170341507001531700227310ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2012, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #ifndef Alembic_AbcCoreAbstract_Tests_Assert_h #define Alembic_AbcCoreAbstract_Tests_Assert_h #include #include #include #include #include #include #include #include #include //-***************************************************************************** static const double VAL_EPSILON = std::numeric_limits::epsilon() * 1024.0; bool almostEqual( const double &a, const double &b, const double &epsilon = VAL_EPSILON ) { return Imath::equalWithAbsError( a, b, epsilon ); } //-***************************************************************************** #define TESTING_ASSERT( TEST ) \ do \ { \ if ( !( TEST ) ) \ { \ std::stringstream strm; \ strm << "ERROR: Failed Test in File: " << __FILE__ << " Line: " \ << __LINE__; \ throw std::runtime_error( strm.str() ); \ } \ } \ while( 0 ) //-***************************************************************************** #define TESTING_MESSAGE_ASSERT( TEST, MSG ) \ do \ { \ if ( !( TEST ) ) \ { \ std::stringstream strm; \ strm << "ERROR: Failed Test in File: " << __FILE__ \ << " Line: " << __LINE__ << " " << MSG; \ throw std::runtime_error( strm.str() ); \ } \ } \ while( 0 ) //-***************************************************************************** #define TESTING_ASSERT_THROW( TEST, EXCEPT ) \ do \ { \ bool passed = false; \ try \ { \ TEST ; \ } \ catch ( const EXCEPT & ) \ { \ passed = true; \ } \ \ if ( !passed ) \ { \ std::stringstream strm; \ strm << "ERROR: Failed Throw in File: " << __FILE__ \ << " Line: " << __LINE__; \ throw std::runtime_error( strm.str() ); \ } \ } \ while( 0 ) //-***************************************************************************** #define TESTING_RUN( TEST, VAL ) \ do \ { \ try \ { \ { \ TEST ; \ } \ \ \ } \ catch ( std::exception &exc ) \ { \ std::cerr << "ERROR: EXCEPTION: " << exc.what() << std::endl; \ VAL ++; \ } \ catch ( ... ) \ { \ std::cerr << "ERROR: UNKNOWN EXCEPTION" << std::endl; \ VAL ++; \ } \ } \ while( 0 ) #endif alembic-1.8.9/lib/Alembic/AbcCoreAbstract/Tests/CMakeLists.txt000066400000000000000000000047401507001531700240570ustar00rootroot00000000000000##-***************************************************************************** ## ## Copyright (c) 2009-2015, ## Sony Pictures Imageworks Inc. and ## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. ## ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are ## met: ## * Redistributions of source code must retain the above copyright ## notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above ## copyright notice, this list of conditions and the following disclaimer ## in the documentation and/or other materials provided with the ## distribution. ## * Neither the name of Industrial Light & Magic nor the names of ## its contributors may be used to endorse or promote products derived ## from this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ## ##-***************************************************************************** INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib) ADD_EXECUTABLE(AbcCoreAbstractTimeSamplingTest TestTimeSampling.cpp) TARGET_LINK_LIBRARIES(AbcCoreAbstractTimeSamplingTest Alembic) ADD_EXECUTABLE(AbcCoreAbstractCompoundPropsTest1 CompoundPropertyTest1.cpp) TARGET_LINK_LIBRARIES(AbcCoreAbstractCompoundPropsTest1 Alembic) ADD_EXECUTABLE(OctessenceBug58 OctessenceBug58.cpp) TARGET_LINK_LIBRARIES(OctessenceBug58 Alembic) ADD_TEST(AbcCoreAbstract_TimeSampling_TEST AbcCoreAbstractTimeSamplingTest) ADD_TEST(AbcCoreAbstract_CompoundProps_TEST1 AbcCoreAbstractCompoundPropsTest1) ADD_TEST(AbcCoreAbstract_OctessenceBug58_TEST OctessenceBug58) alembic-1.8.9/lib/Alembic/AbcCoreAbstract/Tests/CompoundPropertyTest1.cpp000066400000000000000000000101071507001531700262670ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include #include //-***************************************************************************** namespace AO = Alembic::AbcCoreOgawa; namespace ABCA = Alembic::AbcCoreAbstract; using ABCA::chrono_t; using Alembic::Util::float32_t; using Alembic::Util::int32_t; using Alembic::Util::byte_t; using Alembic::Util::Dimensions; //-***************************************************************************** void WriteTestArchive( const std::string &iArchiveName ) { ABCA::MetaData md; md.setUnique( "name", "arkive" ); ABCA::ObjectWriterPtr finalChild; AO::WriteArchive aw; ABCA::ArchiveWriterPtr archive = aw( iArchiveName, md ); ABCA::ObjectWriterPtr topObj = archive->getTop(); // at this point, the archive has a single H5 Group under the root // group called "ABC". { // as things go out of scope, they automatically clean themselves up. // when the archive goes out of scope, it writes itself to disk. md.set( "name", "childObject0" ); ABCA::ObjectWriterPtr archiveChild = topObj->createChild( ABCA::ObjectHeader( "archiveChild", md ) ); // the hdf5 layout of the archive is now "/ABC/archiveChild/" md.set( "name", "childObject1" ); ABCA::ObjectWriterPtr archiveChildChild = archiveChild->createChild( ABCA::ObjectHeader( "archiveChildChild", md ) ); // "/ABC/archiveChild/archiveChildChild" md.set( "name", "childObject2" ); finalChild = archiveChildChild->createChild( ABCA::ObjectHeader( "archiveChildChildChild", md ) ); // "/ABC/archiveChild/archiveChildChild/archiveChildChildChild" } // At this point, only the final child and the archive are still in scope, // but we should still be able to write some properties to the final child, // even though its parents are "gone", and all access needs to be done // hierarchically. } //-***************************************************************************** int main( int, char** ) { const std::string firstArchive( "firstArchive.abc" ); WriteTestArchive( firstArchive ); } alembic-1.8.9/lib/Alembic/AbcCoreAbstract/Tests/OctessenceBug38.cpp000066400000000000000000000316201507001531700247240ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include "Assert.h" #include #include //-***************************************************************************** namespace AbcA = Alembic::AbcCoreAbstract; using namespace Alembic::Util; //-***************************************************************************** void WriteTestArchive( const std::string &iArchiveName ) { AbcA::MetaData md; md.setUnique( "name", "arkive" ); Alembic::AbcCoreOgawa::WriteArchive aw; AbcA::ArchiveWriterPtr archive = aw( iArchiveName, md ); // at this point, the archive has a single H5 Group under the root // group called "ABC". AbcA::ObjectWriterPtr top = archive->getTop(); AbcA::ObjectWriterPtr finalChild; { // as things go out of scope, they automatically clean themselves up. // when the archive goes out of scope, it writes itself to disk. md.set( "name", "childObject0" ); AbcA::ObjectWriterPtr archiveChild = top->createChild( AbcA::ObjectHeader( "archiveChild", md ) ); md.set( "name", "childObject1" ); AbcA::ObjectWriterPtr archiveChildChild = archiveChild->createChild( AbcA::ObjectHeader( "archiveChildChild", md ) ); md.set( "name", "childObject2" ); finalChild = archiveChildChild->createChild( AbcA::ObjectHeader( "archiveChildChildChild", md ) ); } // OK, let's write some properties. First, get a shared_ptr to the // CompoundPropertyWriter for the final object. AbcA::CompoundPropertyWriterPtr fcProps = finalChild->getProperties(); const AbcA::TimeSamplingType tsampType( 2, 2.0 ); // Now, make some sample data. We'll just use some ints. const size_t numVals = 50; const Dimensions dims( numVals ); const AbcA::DataType dtype( Alembic::Util::kInt32POD, 1 ); AbcA::PropertyHeader ph( "firstInt32ArrayProp", AbcA::kArrayProperty, AbcA::MetaData(), dtype, tsampType ); AbcA::ArrayPropertyWriterPtr arrayPropWtrPtr = fcProps->createArrayProperty( ph ); std::vector intData0; for ( size_t i = 0 ; i < numVals ; ++i ) { intData0.push_back( i ); } AbcA::ArraySample as0( (const void*)&(intData0.front() ), dtype, dims ); arrayPropWtrPtr->setSample( 0, 0.0, as0 ); std::vector intData1; for ( size_t i = 0 ; i < 30 ; ++i ) { intData1.push_back( i + 1 ); } AbcA::ArraySample as1( (const void*)&( intData1.front() ), dtype, Dimensions( 30 ) ); arrayPropWtrPtr->setSample( 1, 1.0, as1 ); std::vector intData2; for ( size_t i = 0 ; i < numVals ; ++i ) { intData2.push_back( i + 2 ); } AbcA::ArraySample as2( (const void*)&( intData2.front() ), dtype, dims ); arrayPropWtrPtr->setSample( 2, 2.0, as2 ); std::vector intData3; for ( size_t i = 0 ; i < numVals ; ++i ) { intData3.push_back( i + 3 ); } AbcA::ArraySample as3( (const void*)&( intData3.front() ), dtype, dims ); arrayPropWtrPtr->setSample( 3, 3.0, as3 ); std::vector intData4; for ( size_t i = 0 ; i < numVals ; ++i ) { intData4.push_back( i + 4 ); } AbcA::ArraySample as4( (const void*)&( intData4.front() ), dtype, dims ); arrayPropWtrPtr->setSample( 4, 4.0, as4 ); std::vector intData5; for ( size_t i = 0 ; i < 2 ; ++i ) { intData5.push_back( i + 5 ); } AbcA::ArraySample as5( (const void*)&( intData5.front() ), dtype, Dimensions( 2 ) ); arrayPropWtrPtr->setSample( 5, 5.0, as5 ); std::vector intData6; for ( size_t i = 0 ; i < 78 ; ++i ) { intData6.push_back( i + 6 ); } AbcA::ArraySample as6( (const void*)&( intData6.front() ), dtype, Dimensions( 78 ) ); arrayPropWtrPtr->setSample( 6, 6.0, as6 ); // OK, let's try a second array property, Acyclic time sampling AbcA::PropertyHeader ph2( "secondInt32ArrayProp", AbcA::kArrayProperty, AbcA::MetaData(), dtype, AbcA::TimeSamplingType( AbcA::TimeSamplingType::kAcyclic ) ); AbcA::ArrayPropertyWriterPtr secondArrayProp = fcProps->createArrayProperty( ph2 ); std::vector secondPropDataVec0; for ( size_t i = 0 ; i < 2 ; ++i ) { secondPropDataVec0.push_back( i ); } AbcA::ArraySample as2nd0( (const void*)&( secondPropDataVec0.front() ), dtype, Dimensions( 2 ) ); secondArrayProp->setSample( 0, 0.0, as2nd0 ); std::vector secondPropDataVec1; for ( size_t i = 0 ; i < 10 ; ++i ) { secondPropDataVec1.push_back( i + 1 ); } AbcA::ArraySample as2nd1( (const void*)&( secondPropDataVec1.front() ), dtype, Dimensions( 10 ) ); secondArrayProp->setSample( 1, 0.5, as2nd1 ); std::vector secondPropDataVec2; for ( size_t i = 0 ; i < 23 ; ++i ) { secondPropDataVec2.push_back( i + 2 ); } AbcA::ArraySample as2nd2( (const void*)&( secondPropDataVec2.front() ), dtype, Dimensions( 23 ) ); secondArrayProp->setSample( 2, 2.3, as2nd2 ); // OK, now a ScalarProperty. AbcA::PropertyHeader scalarPH( "scalarProp", AbcA::kScalarProperty, AbcA::MetaData(), AbcA::DataType( Alembic::Util::kFloat32POD, 1 ), tsampType ); AbcA::ScalarPropertyWriterPtr scalarPropWtrPtr = fcProps->createScalarProperty( scalarPH ); float32_t scalarVal = 42.0f; scalarPropWtrPtr->setSample( 0, 0.0, (const void*)&scalarVal ); } //-***************************************************************************** void ReadTestArchive( const std::string &iArchiveName ) { // When opening an archive for reading, you can pass in a pointer to // an AbcA::ReadArraySampleCache, but if you don't, it will construct one // for you by default. If you don't want to cache, just pass in NULL // as the second argument. Alembic::AbcCoreOgawa::ReadArchive ar; AbcA::ArchiveReaderPtr arkive = ar( iArchiveName ); // Just stashing away a compound property reader pointer; we know the last // child object in our hierarchy has all the properties, because we created // it in the WriteTestArchive function. AbcA::CompoundPropertyReaderPtr fcProps; // Now do a depth-first traversal of our archive; this is a little ugly AbcA::ObjectReaderPtr tmpOrp1; AbcA::ObjectReaderPtr tmpOrp2 = arkive->getTop(); while ( true ) { tmpOrp1 = tmpOrp2; if ( tmpOrp1->getNumChildren() < 1 ) { std::cout << "Found my last lonely child, named " << tmpOrp1->getFullName() << std::endl; fcProps = tmpOrp1->getProperties(); std::cout << "It has " << fcProps->getNumProperties() << " sub-properties." << std::endl; break; } tmpOrp2 = tmpOrp1->getChild( 0 ); } // OK, fcProps is a shared pointer to the compound property reader that // was in the last child object of the archive. Let's get the simple // properties out of it. AbcA::ScalarPropertyReaderPtr sProp; AbcA::ArrayPropertyReaderPtr aProp0; AbcA::ArrayPropertyReaderPtr aProp1; for ( size_t i = 0 ; i < fcProps->getNumProperties() ; ++i ) { AbcA::BasePropertyReaderPtr bp = fcProps->getProperty( i ); std::cout << "Found " << bp->getName() << std::endl; if ( bp->isScalar() ) { sProp = bp->asScalarPtr(); std::cout << "sProp has " << sProp->getNumSamples() << " samples." << std::endl; } if ( bp->isArray() && bp->getName() == "secondInt32ArrayProp" ) { aProp1 = bp->asArrayPtr(); std::cout << "aProp1 has " << aProp1->getNumSamples() << " samples." << std::endl; } if ( bp->isArray() && bp->getName() == "firstInt32ArrayProp" ) { aProp0 = bp->asArrayPtr(); std::cout << "aProp0 has " << aProp0->getNumSamples() << " samples." << std::endl; } } // OK, now we have pointers to the two properties, one scalar, the other // array. Let's read the scalar one first. for ( size_t i = 0 ; i < sProp->getNumSamples() ; ++i ) { float32_t sVal = 0; sProp->getSample( i, (void*)(&sVal) ); TESTING_ASSERT( sVal == 42.0 ); std::cout << sProp->getName() << " at sample " << i << " has the value " << sVal << std::endl << std::endl; } // OK, now the first int array property. AbcA::ArraySamplePtr samp; std::cout << "FIRST INT ARRAY PROPERTY (Cyclic time sampling)" << std::endl; for ( size_t i = 0 ; i < aProp0->getNumSamples() ; ++i ) { aProp0->getSample( i, samp ); const AbcA::TimeSampling ts = aProp0->getTimeSampling(); size_t numPoints = samp->getDimensions().numPoints(); TESTING_ASSERT( (AbcA::chrono_t)i == ts.getSampleTime( i ) ); std::cout << "At Sample " << i << ", " << aProp0->getName() << " is at time " << ts.getSampleTime( i ) << " and has " << numPoints << " points, with the values: " << std::endl; int32_t *vals = (int32_t*)(samp->getData()); for ( size_t j = 0 ; j < numPoints ; ++j ) { TESTING_ASSERT( vals[j] == i + j ); std::cout << j << ": " << vals[j] << ", "; } std::cout << std::endl << std::endl; samp->reset(); } // now the second int array std::cout << "SECOND INT ARRAY PROPERTY (Acyclic time sampling)" << std::endl; for ( size_t i = 0 ; i < aProp1->getNumSamples() ; ++i ) { aProp1->getSample( i, samp ); const AbcA::TimeSampling ts = aProp1->getTimeSampling(); size_t numPoints = samp->getDimensions().numPoints(); std::cout << "At Sample " << i << ", " << aProp1->getName() << " is at time " << ts.getSampleTime( i ) << " and has " << numPoints << " points," << std::endl << "with the values: " << std::endl; int32_t *vals = (int32_t*)(samp->getData()); for ( size_t j = 0 ; j < numPoints ; ++j ) { TESTING_ASSERT( vals[j] == i + j ); std::cout << j << ": " << vals[j] << ", "; } std::cout << std::endl << std::endl; samp->reset(); } } //-***************************************************************************** int main( int, char** ) { const std::string firstArchive( "firstArchive.abc" ); WriteTestArchive( firstArchive ); ReadTestArchive( firstArchive ); return 0; } alembic-1.8.9/lib/Alembic/AbcCoreAbstract/Tests/OctessenceBug58.cpp000066400000000000000000000075711507001531700247360ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2011, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include #include #include //-***************************************************************************** namespace AO = Alembic::AbcCoreOgawa; namespace AA = Alembic::AbcCoreAbstract; //-***************************************************************************** void WriteTestArchive( const std::string &iArchiveName ) { std::cout << "Entered WriteTestArchive()" << std::endl; AA::MetaData md; AO::WriteArchive aw; // declaring the object writer prior to opening the archive causes it to // stay open when the archive goes out of scope, throwing an exception. AA::ObjectWriterPtr finalChild; AA::ArchiveWriterPtr arkive = aw( iArchiveName, md ); // interestingly, declaring topObj prior to opening the archive for // writing doesn't crash it. AA::ObjectWriterPtr topObj = arkive->getTop(); finalChild = topObj->createChild( AA::ObjectHeader( "ac0", md ) ); std::cout << "About to leave WriteTestArchive()." << std::endl; } //-***************************************************************************** void ReadTestArchive( const std::string &iArchiveName ) { std::cout << "Entered ReadTestArchive()" << std::endl; AO::ReadArchive ar; // declaring the object reader before opening the archive causes it to stay // open when the archive tries to close. AA::ObjectReaderPtr finalChild; AA::ArchiveReaderPtr arkive = ar( iArchiveName ); AA::ObjectReaderPtr topObj = arkive->getTop(); finalChild = topObj->getChild( 0 ); std::cout << "finalChild->getFullName(): " << finalChild->getFullName() << std::endl; std::cout << "About to leave ReadTestArchive()" << std::endl; } //-***************************************************************************** int main( int, char** ) { const std::string firstArchive( "octessence58.abc" ); WriteTestArchive( firstArchive ); ReadTestArchive( firstArchive ); return 0; } alembic-1.8.9/lib/Alembic/AbcCoreAbstract/Tests/TestTimeSampling.cpp000066400000000000000000000527021507001531700252550ustar00rootroot00000000000000//-***************************************************************************** // // Copyright (c) 2009-2014, // Sony Pictures Imageworks Inc. and // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Sony Pictures Imageworks, nor // Industrial Light & Magic, nor the names of their contributors may be used // to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //-***************************************************************************** #include #include "Assert.h" #include #include #include #include #include #include //-***************************************************************************** namespace AbcA = Alembic::AbcCoreAbstract::v12; using AbcA::chrono_t; using AbcA::index_t; typedef std::vector TimeVector; //-***************************************************************************** void validateTimeSampling( const AbcA::TimeSampling &timeSampling, const AbcA::TimeSamplingType &timeSamplingType, const TimeVector &timeVector, const size_t numSamplesPerCycle, const chrono_t timePerCycle ) { const chrono_t period = timeSamplingType.getTimePerCycle(); TESTING_MESSAGE_ASSERT( period == timePerCycle, "calculated cycle period does not match given time/cycle" ); std::cout << "***********************************************************" << std::endl; if ( timeSamplingType.isUniform() ) { std::cout << "time sampling type is uniform" << std::endl; } if ( timeSamplingType.isCyclic() ) { std::cout << "time sampling type is cyclic" << std::endl; } if ( timeSamplingType.isAcyclic() ) { std::cout << "time sampling type is acyclic" << std::endl; } std::cout << "Number of samples per cycle is " << timeSamplingType.getNumSamplesPerCycle() << std::endl << std::endl; std::cout << "Given times:" << std::endl; for ( size_t i = 0 ; i < timeVector.size() ; ++i ) { std::cout << i << ": " << timeVector[i] << " " << std::endl; } std::cout << std::endl << "with a period of " << period << std::endl << std::endl; TESTING_MESSAGE_ASSERT( timeSamplingType.isAcyclic() || numSamplesPerCycle == timeSampling.getNumStoredTimes(), "Number of samples given doesn't match number returned" ); //-************************************************************************* // acyclic case if ( timePerCycle == AbcA::TimeSamplingType::AcyclicTimePerCycle() || numSamplesPerCycle == AbcA::TimeSamplingType::AcyclicNumSamples() ) { TESTING_MESSAGE_ASSERT( timePerCycle == AbcA::TimeSamplingType::AcyclicTimePerCycle() && numSamplesPerCycle == AbcA::TimeSamplingType::AcyclicNumSamples(), "Given time and samples per cycle should be infinite." ); TESTING_MESSAGE_ASSERT( timeSamplingType.isAcyclic(), "Time sampling should be acyclic." ); } // uniform case else if ( numSamplesPerCycle == 1 ) { TESTING_MESSAGE_ASSERT( timeSamplingType.isUniform(), "Time sampling should be uniform." ); } // cyclic case else if ( numSamplesPerCycle > 0 && timePerCycle > 0.0 ) { TESTING_MESSAGE_ASSERT( timeSamplingType.isCyclic(), "Time sampling should be cyclic." ); } else { TESTING_MESSAGE_ASSERT( false, "Could not validate time sampling." ); } } //-***************************************************************************** template void testTimeSampling( const AbcA::TimeSampling &timeSampling, const AbcA::TimeSamplingType &timeSamplingType, index_t numSamples ) { const TIME timePerCycle = timeSamplingType.getTimePerCycle(); const index_t numSamplesPerCycle = timeSamplingType.getNumSamplesPerCycle(); const index_t numStoredTimes = timeSampling.getNumStoredTimes(); TESTING_MESSAGE_ASSERT( timeSamplingType.isAcyclic() || numStoredTimes == numSamplesPerCycle, "The number of stored times in the vector of times must match the " "number of samples per cycle." ); std::cout << "Here are the time sample times, contained in the " << "TimeSampling instance." << std::endl << "Only the first " << numStoredTimes << " values are stored; " << "the rest are computed." << std::endl << std::endl; for ( index_t i = 0; i < numSamples ; ++i ) { std::cout << i << ": " << timeSampling.getSampleTime( i ) << std::endl; TIME timeI = timeSampling.getSampleTime( i ); index_t floorIndex = timeSampling.getFloorIndex( timeI, numSamples ).first; index_t ceilIndex = timeSampling.getCeilIndex( timeI, numSamples ).first; index_t nearIndex = timeSampling.getNearIndex( timeI, numSamples ).first; // floor std::stringstream floorMsg; floorMsg << "Sample " << i << " is time " << timeI << ", and getFloorIndex( " << timeI << " ) is " << floorIndex << ". It should be " << i; TESTING_MESSAGE_ASSERT( floorIndex == i, floorMsg.str() ); // ceiling std::stringstream ceilMsg; ceilMsg << "Sample " << i << " is time " << timeI << ", and getCeilIndex( " << timeI << " ) is " << ceilIndex << ". It should be " << i; TESTING_MESSAGE_ASSERT( ceilIndex == i, ceilMsg.str() ); // nearest std::stringstream nearMsg; nearMsg << "Sample " << i << " is time " << timeI << ", and getNearIndex( " << timeI << " ) is " << nearIndex << ". It should be " << i; TESTING_MESSAGE_ASSERT( nearIndex == i, nearMsg.str() ); chrono_t smidgeOver = 0.01; chrono_t smidgeUnder = 0.01; index_t loi = i; index_t hii = i; // base smidge off of the previous time if ( i > 0 ) { TIME timeIm1 = timeSampling.getSampleTime( i - 1 ); TESTING_MESSAGE_ASSERT( timeIm1 < timeI, "Times should be monotonically increasing." ); smidgeUnder = ( timeI - timeIm1 ) / 4.0; loi = i - 1; } // base smidge over on a future time if ( i < numSamples - 1 ) { chrono_t timeIp1 = timeSampling.getSampleTime( i + 1 ); smidgeOver = ( timeIp1 - timeI ) / 4.0; hii = i + 1; } chrono_t smidgeOverTimeI = timeI + smidgeOver; chrono_t smidgeUnderTimeI = timeI - smidgeUnder; // floor index TESTING_MESSAGE_ASSERT( timeSampling.getFloorIndex( smidgeOverTimeI, numSamples ).first == i, "Time a smidge over time sampled at 'i' should have a floor index " "of 'i'." ); TESTING_MESSAGE_ASSERT( timeSampling.getFloorIndex( smidgeUnderTimeI, numSamples ).first == loi, "Time a smidge under time sampled at 'i' should have a floor " "index of 'i - 1'." ); // ceiling index TESTING_MESSAGE_ASSERT( timeSampling.getCeilIndex( smidgeOverTimeI, numSamples ).first == hii, "Time a smidge over time sampled at 'i' should have a ceiling " "index of 'i + 1'." ); TESTING_MESSAGE_ASSERT( timeSampling.getCeilIndex( smidgeUnderTimeI, numSamples ).first == i, "Time a smidge under time sampled at 'i' should have a ceiling " "index of 'i'." ); // near index TESTING_MESSAGE_ASSERT( timeSampling.getNearIndex( smidgeOverTimeI, numSamples ).first == i, "Time a smidge over time sampled at 'i' should have a nearest " "index of 'i'." ); TESTING_MESSAGE_ASSERT( timeSampling.getCeilIndex( smidgeUnderTimeI, numSamples ).first == i, "Time a smidge under time sampled at 'i' should have a nearest " "index of 'i'." ); if ( ( timeSamplingType.isCyclic() || timeSamplingType.isUniform() ) && i > numSamplesPerCycle ) { TIME cur = timeSampling.getSampleTime( i ); TIME prev = timeSampling.getSampleTime( i - numSamplesPerCycle ); TESTING_MESSAGE_ASSERT( Imath::equalWithAbsError( (double)( cur - prev ), (double)timePerCycle, 0.00001 ), "Calculated time per cycle is different than given." ); } } std::cout << std::endl << std::endl; } //-***************************************************************************** template void testCyclicTime1() { // random weird cycle TimeVector tvec; tvec.push_back( -0.7 ); tvec.push_back( -0.1 ); tvec.push_back( 0.2 ); const chrono_t timePerCycle = 1.0; // 0.1 more time than tvec[2] - tvec[0] const size_t numSamplesPerCycle = 3; const size_t numSamps = 97; const AbcA::TimeSamplingType tSampTyp( numSamplesPerCycle, timePerCycle ); const AbcA::TimeSampling tSamp( tSampTyp, tvec ); TESTING_MESSAGE_ASSERT( tSampTyp.isCyclic(), "Should be cyclic." ); std::cout << "Testing cyclic time, 1" << std::endl; validateTimeSampling( tSamp, tSampTyp, tvec, numSamplesPerCycle, timePerCycle ); testTimeSampling