HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Foundation.h
Go to the documentation of this file.
1 //-*****************************************************************************
2 //
3 // Copyright (c) 2013,
4 // Sony Pictures Imageworks Inc. and
5 // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
6 //
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are
11 // met:
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above
15 // copyright notice, this list of conditions and the following disclaimer
16 // in the documentation and/or other materials provided with the
17 // distribution.
18 // * Neither the name of Sony Pictures Imageworks, nor
19 // Industrial Light & Magic, nor the names of their contributors may be used
20 // to endorse or promote products derived from this software without specific
21 // prior written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 //
35 //-*****************************************************************************
36 
37 #ifndef _Alembic_AbcCoreOgawa_Foundation_h_
38 #define _Alembic_AbcCoreOgawa_Foundation_h_
39 
41 
42 #include <Alembic/Util/All.h>
43 
44 #include <Alembic/Ogawa/All.h>
45 
46 #include <vector>
47 #include <string>
48 #include <map>
49 
50 #include <iostream>
51 
52 #include <stdlib.h>
53 #include <stdio.h>
54 #include <assert.h>
55 #include <string.h>
56 
57 #define ALEMBIC_OGAWA_FILE_VERSION 0
58 
59 //-*****************************************************************************
60 
61 namespace Alembic {
62 namespace AbcCoreOgawa {
63 namespace ALEMBIC_VERSION_NS {
64 
65 //-*****************************************************************************
66 namespace AbcA = ::Alembic::AbcCoreAbstract;
67 
68 using AbcA::index_t;
69 using AbcA::chrono_t;
70 
71 //-*****************************************************************************
72 typedef Alembic::Util::weak_ptr<AbcA::ObjectWriter> WeakOwPtr;
73 typedef Alembic::Util::weak_ptr<AbcA::BasePropertyWriter> WeakBpwPtr;
74 
75 typedef Alembic::Util::weak_ptr<AbcA::ObjectReader> WeakOrPtr;
76 typedef Alembic::Util::weak_ptr<AbcA::BasePropertyReader> WeakBprPtr;
77 
78 //-*****************************************************************************
80 {
82  {
83  isScalarLike = true;
84  isHomogenous = true;
85  nextSampleIndex = 0;
87  lastChangedIndex = 0;
89  }
90 
91  // for compounds
93  const AbcA::MetaData &iMetaData ) :
94  header( iName, iMetaData )
95  {
96  isScalarLike = true;
97  isHomogenous = true;
98  nextSampleIndex = 0;
100  lastChangedIndex = 0;
101  timeSamplingIndex = 0;
102  }
103 
104  // for scalar and array properties
106  AbcA::PropertyType iPropType,
107  const AbcA::MetaData &iMetaData,
108  const AbcA::DataType &iDataType,
109  const AbcA::TimeSamplingPtr & iTsamp,
110  Util::uint32_t iTimeSamplingIndex ) :
111  header( iName, iPropType, iMetaData, iDataType, iTsamp ),
112  timeSamplingIndex( iTimeSamplingIndex )
113  {
114  isScalarLike = true;
115  isHomogenous = true;
116  nextSampleIndex = 0;
117  firstChangedIndex = 0;
118  lastChangedIndex = 0;
119  }
120 
121  // convenience function that makes sure the incoming index is ok, and
122  // offsets it to the proper index within the Ogawa group
123  size_t verifyIndex( index_t iIndex )
124  {
125  // Verify sample index
126  ABCA_ASSERT( iIndex >= 0 &&
127  iIndex < nextSampleIndex,
128  "Invalid sample index: " << iIndex
129  << ", should be between 0 and " << nextSampleIndex - 1 );
130 
131  Util::uint32_t index = ( Util::uint32_t ) iIndex;
132  if ( index < firstChangedIndex )
133  {
134  return 0;
135  }
136  // constant case
137  else if ( firstChangedIndex == lastChangedIndex &&
138  firstChangedIndex == 0 )
139  {
140  return 0;
141  }
142  else if ( index >= lastChangedIndex )
143  {
144  return ( size_t ) ( lastChangedIndex - firstChangedIndex + 1 );
145  }
146 
147  return ( size_t ) ( index - firstChangedIndex + 1 );
148  }
149 
150  // The header which defines this property.
152 
154 
156 
157  // Index of the next sample to write
158  Util::uint32_t nextSampleIndex;
159 
160  // Index representing the first sample that is different from sample 0
161  Util::uint32_t firstChangedIndex;
162 
163  // Index representing the last sample in which a change has occured
164  // There is no need to repeat samples if they are the same between this
165  // index and nextSampleIndex
166  Util::uint32_t lastChangedIndex;
167 
168  // Index representing which TimeSampling from the ArchiveWriter to use.
169  Util::uint32_t timeSamplingIndex;
170 };
171 
172 typedef Alembic::Util::shared_ptr<PropertyHeaderAndFriends> PropertyHeaderPtr;
173 typedef std::vector<PropertyHeaderPtr> PropertyHeaderPtrs;
174 
175 typedef Alembic::Util::shared_ptr<AbcA::ObjectHeader> ObjectHeaderPtr;
176 
177 } // End namespace ALEMBIC_VERSION_NS
178 
179 using namespace ALEMBIC_VERSION_NS;
180 
181 } // End namespace AbcCoreOgawa
182 } // End namespace Alembic
183 
184 #endif
std::vector< PropertyHeaderPtr > PropertyHeaderPtrs
Definition: Foundation.h:173
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
Alembic::Util::shared_ptr< AbcA::ObjectHeader > ObjectHeaderPtr
Definition: Foundation.h:175
PropertyHeaderAndFriends(const std::string &iName, AbcA::PropertyType iPropType, const AbcA::MetaData &iMetaData, const AbcA::DataType &iDataType, const AbcA::TimeSamplingPtr &iTsamp, Util::uint32_t iTimeSamplingIndex)
Definition: Foundation.h:105
Alembic::Util::weak_ptr< AbcA::BasePropertyReader > WeakBprPtr
Definition: Foundation.h:76
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Alembic::Util::weak_ptr< AbcA::ObjectWriter > WeakOwPtr
Definition: Foundation.h:72
Alembic::Util::weak_ptr< AbcA::BasePropertyWriter > WeakBpwPtr
Definition: Foundation.h:73
PropertyHeaderAndFriends(const std::string &iName, const AbcA::MetaData &iMetaData)
Definition: Foundation.h:92
Alembic::Util::shared_ptr< PropertyHeaderAndFriends > PropertyHeaderPtr
Definition: Foundation.h:172
GLuint index
Definition: glcorearb.h:785
Alembic::Util::weak_ptr< AbcA::ObjectReader > WeakOrPtr
Definition: Foundation.h:75
#define ABCA_ASSERT(COND, TEXT)
Definition: Foundation.h:99
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104