Go to the documentation of this file.
71 #include <sys/types.h>
93 bool isAbsolute = (filename[0] ==
'/'
95 || filename[0] ==
'\\'
96 || (isalpha(filename[0]) && filename[1] ==
':')
104 for (
size_t i = 0, size =
_searchdirs.size(); i < size; i++) {
108 if (stat(buffer.c_str(), &statbuf) == 0) {
109 filename = buffer.c_str();
114 std::string errstr =
"Can't find ptex file: ";
116 error = errstr.
c_str();
129 if (!reader->
ok())
return 0;
143 const char* pathToOpen = filename;
146 reader->
open(pathToOpen, error);
154 size_t newMemUsed = 0;
158 if (reader != newreader) {
182 if (maxFiles <= 0) maxFiles = 100;
184 return new PtexReaderCache(maxFiles, maxMem, premultiply, inputHandler, errorHandler);
194 mruList->
files[slot] = reader;
219 size_t memUsedChange = 0, filesOpenChange = 0;
222 do { reader = mruList->
files[i]; }
while (!reader);
223 mruList->
files[i] = 0;
227 filesOpenChange += opens;
228 if (opens || blockReads) {
244 if (shouldPruneFiles) {
247 if (shouldPruneData) {
257 if (numToClose > 0) {
272 size_t memUsedChangeTotal = 0;
274 while (memUsed + memUsedChangeTotal >
_maxMem) {
277 size_t memUsedChange;
278 if (reader->
tryPrune(memUsedChange)) {
280 memUsedChangeTotal += memUsedChange;
300 if (reader)
purge(reader);
305 size_t memUsedChange;
306 if (reader->
tryPurge(memUsedChange)) {
313 size_t memUsedChange;
314 if (reader->
tryPurge(memUsedChange)) {
Value tryInsert(Key &key, Value value, size_t &newMemUsed)
static PtexCache * create(int maxFiles, size_t maxMem, bool premultiply=false, PtexInputHandler *inputHandler=0, PtexErrorHandler *errorHandler=0)
Create a cache with the specified limits.
virtual void getStats(Stats &stats)
Get stats.
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary forms
void adjustMemUsed(size_t amount)
PtexLruList< PtexCachedReader, &PtexCachedReader::_activeFilesItem > _activeFiles
#define PTEX_NAMESPACE_END
File-handle and memory cache for reading ptex files.
PtexCachedReader *volatile files[numMruFiles]
PtexLruList< PtexCachedReader, &PtexCachedReader::_openFilesItem > _openFiles
virtual void release()
Release resources held by this pointer (pointer becomes invalid).
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR NONINFRINGEMENT AND TITLE ARE DISCLAIMED IN NO EVENT SHALL WALT DISNEY THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT
bool tryPrune(size_t &memUsedChange)
PTEX SOFTWARE Copyright Disney Enterprises
virtual void purgeAll()
Remove all texture files from the cache.
Custom handler interface redirecting Ptex error messages.
MruList *volatile _prevMruList
size_t getMemUsedChange()
find_package(Doxygen) if(DOXYGEN_FOUND) add_custom_command(OUTPUT $
size_t getBlockReadsChange()
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without modification
if(WIN32) add_definitions(/DPTEX_EXPORTS) endif(WIN32) configure_file(PtexVersion.h.in $
Half-precision (16-bit) floating-point type.
void operator()(PtexCachedReader *reader)
bool pendingPurge() const
Triangle filter kernel (in normalized triangle coords)
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR NONINFRINGEMENT AND TITLE ARE DISCLAIMED IN NO EVENT SHALL WALT DISNEY THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE
Cache for reading Ptex texture files.
bool open(const char *path, Ptex::String &error)
virtual PtexTexture * get(const char *path, Ptex::String &error)
Access a texture.
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY
std::vector< std::string > _searchdirs
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Pictures
Interface for writing data to a ptex file.
Common data structures and enums used throughout the API.
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are met
void logRecentlyUsed(PtexCachedReader *reader)
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED TO
Interface for reading data from a ptex file.
MruList *volatile _mruList
size_t memUsedChangeTotal
volatile size_t _filesOpen
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR NONINFRINGEMENT AND TITLE ARE DISCLAIMED IN NO EVENT SHALL WALT DISNEY THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR NONINFRINGEMENT AND TITLE ARE DISCLAIMED IN NO EVENT SHALL WALT DISNEY THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT LIABILITY
void adjustFilesOpen(size_t amount)
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR NONINFRINGEMENT AND TITLE ARE DISCLAIMED IN NO EVENT SHALL WALT DISNEY THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY EXEMPLARY
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR NONINFRINGEMENT AND TITLE ARE DISCLAIMED IN NO EVENT SHALL WALT DISNEY THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 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 BASED ON ANY THEORY OF LIABILITY
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE
bool findFile(const char *&filename, std::string &buffer, Ptex::String &error)
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Disney
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR NONINFRINGEMENT AND TITLE ARE DISCLAIMED IN NO EVENT SHALL WALT DISNEY THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY INCIDENTAL
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR NONINFRINGEMENT AND TITLE ARE DISCLAIMED IN NO EVENT SHALL WALT DISNEY THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN CONTRACT
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR NONINFRINGEMENT AND TITLE ARE DISCLAIMED IN NO EVENT SHALL WALT DISNEY THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY SPECIAL
Public API classes for reading, writing, caching, and filtering Ptex files.
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright notice
PtexVersion h ONLY set(SRCS PtexCache.cpp PtexFilters.cpp PtexHalf.cpp PtexReader.cpp PtexSeparableFilter.cpp PtexSeparableKernel.cpp PtexTriangleFilter.cpp PtexTriangleKernel.cpp PtexUtils.cpp PtexWriter.cpp) if(PTEX_BUILD_STATIC_LIBS) add_library(Ptex_static STATIC $
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures BUT NOT LIMITED THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR NONINFRINGEMENT AND TITLE ARE DISCLAIMED IN NO EVENT SHALL WALT DISNEY PICTURES
const char * c_str() const
bool tryPurge(size_t &memUsedChange)
set_target_properties(Ptex_static PROPERTIES OUTPUT_NAME Ptex) target_include_directories(Ptex_static PUBLIC $< INSTALL_INTERFACE
virtual void purge(PtexTexture *)
Remove a texture file from the cache.
PTEX SOFTWARE Copyright Disney Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *The names Walt Disney Walt Disney Animation Studios or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures INCLUDING
static const int numMruFiles