HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TIL_NullFilter.C
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE 'AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  */
26 
27 #include "TIL_NullFilter.h"
28 #include <FS/UT_DSO.h>
29 #include <UT/UT_EnvControl.h>
30 #include <UT/UT_Debug.h>
31 #include <UT/UT_DSOVersion.h>
32 #include <UT/UT_WorkArgs.h>
33 #include <stdio.h>
34 #include <stdarg.h>
35 
36 TIL_NullFilter::TIL_NullFilter()
37  : myVerbose(false)
38 {
39 }
40 
41 bool
42 TIL_NullFilter::setOptions(const UT_Options &o)
43 {
44  bool bval;
45  if (o.importOption("verbose", bval))
46  myVerbose = bval;
47 
48  if (myVerbose)
49  {
50  UTformat("{}: options:\n", className());
51  o.dump();
52  }
53  return true;
54 }
55 
56 TIL_NullFilter::~TIL_NullFilter()
57 {
58 }
59 
60 static void
61 dumpRasterInfo(const char *name, const PXL_Raster *rp)
62 {
63  UTformat(" raster[{}]: {}x{} - {} - {}\n",
64  name,
65  rp->getXres(),
66  rp->getYres(),
67  PXLdataFormat(rp->getFormat()),
68  PXLpacking(rp->getPacking()));
69 }
70 
71 bool
72 TIL_NullFilter::apply(PXL_Raster *raster)
73 {
74  // TODO: Here's where we'd actually change the raster
75  if (myVerbose)
76  {
77  UTformat("{} process raster\n", className());
78  dumpRasterInfo("", raster);
79 
80  UTformat(" {} extra rasters:\n", myAuxPlanes.size());
81  for (const auto &item : myAuxPlanes)
82  UTformat(" - {}: {}\n", item.first, item.second);
83  UTformat(" ErrorString: '{}'", myErrorString);
84  }
85  return true;
86 }
87 
88 void
90 {
91  // This method gets called when starting a new image. There may be
92  // multiple calls to apply() if there are multiple AOVs which are filtered.
93  //
94  // Must call the base-class reset
96 }
97 
98 namespace
99 {
100  struct Factory final : public TIL_RasterFilter::Factory
101  {
102  Factory()
103  {
104  }
105  ~Factory() override
106  {
107  }
108  const UT_StringHolder &name() const override
109  {
110  static constexpr UT_StringLit theName("null_filter");
111  return theName.asHolder();
112  }
113  const UT_StringHolder &label() const override
114  {
115  static constexpr UT_StringLit theName("Null Filter");
116  return theName.asHolder();
117  }
118  UT_UniquePtr<TIL_RasterFilter> newFilter() const override
119  {
120  return UTmakeUnique<TIL_NullFilter>();
121  }
122  };
123 }
124 
125 void
127 {
128  // Register different filters
129  UTdebugFormat("Registering Null Image Filter");
130  TIL_RasterFilter::registerFactory(UTmakeUnique<Factory>());
131 }
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
exint getYres() const
Definition: PXL_Raster.h:98
PXL_API const char * PXLdataFormat(PXL_DataFormat f)
void dump(std::ostream &os) const
Writes a JSON dump to ostream of the current options.
PXL_DataFormat getFormat() const
Definition: PXL_Raster.h:102
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
PXL_Packing getPacking() const
Definition: PXL_Raster.h:103
GLboolean reset
Definition: glad.h:5138
HUSD_API const char * raster()
virtual void reset()
GLuint const GLchar * name
Definition: glcorearb.h:786
static void registerFactory(UT_UniquePtr< Factory > factory)
void newRasterFilter()
A map of string to various well defined value types.
Definition: UT_Options.h:84
The factory to define a filter.
size_t UTformat(FILE *file, const char *format, const Args &...args)
Definition: UT_Format.h:657
exint getXres() const
Definition: PXL_Raster.h:97
PXL_API const char * PXLpacking(PXL_Packing p)
bool importOption(const UT_StringRef &name, int &value) const
#define UTdebugFormat(...)
Definition: UT_Debug.h:144