BRL-CAD
Loading...
Searching...
No Matches
defines.h
Go to the documentation of this file.
1/* D E F I N E S . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2011-2026 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20/** @addtogroup icv_defines
21 *
22 * @brief
23 * Definitions used in the LIBICV image processing library.
24 *
25 */
26
27#ifndef ICV_DEFINES_H
28#define ICV_DEFINES_H
29
30#include "common.h"
31#include <stddef.h> /* for size_t */
32
33/** @{ */
34/** @file icv/defines.h */
35
37
38#ifndef ICV_EXPORT
39# if defined(ICV_DLL_EXPORTS) && defined(ICV_DLL_IMPORTS)
40# error "Only ICV_DLL_EXPORTS or ICV_DLL_IMPORTS can be defined, not both."
41# elif defined(ICV_DLL_EXPORTS)
42# define ICV_EXPORT COMPILER_DLLEXPORT
43# elif defined(ICV_DLL_IMPORTS)
44# define ICV_EXPORT COMPILER_DLLIMPORT
45# else
46# define ICV_EXPORT
47# endif
48#endif
49
50typedef enum {
53 /* Add here for format addition like CMYKA, HSV, others */
55
60
61/* Define Various Flags */
62#define ICV_NULL_IMAGE 0X0001
63#define ICV_SANITIZED 0X0002
64#define ICV_OPERATIONS_MODE 0x0004
65#define ICV_UNDEFINED_1 0x0008
66
67/**
68 * Optional rendering metadata that can be embedded in image files (e.g., PNG
69 * tEXt chunks). When present, it records the scene and camera setup used to
70 * produce the image, enabling exact ray reconstruction for debugging with nirt.
71 *
72 * All floating-point values are stored as full-precision doubles so they can
73 * be serialised with std::numeric_limits<double>::max_digits10 significant
74 * digits and read back without loss.
75 */
77 char *db_filename; /**< @brief path to the .g geometry database */
78 char *objects; /**< @brief space-separated list of top-level objects */
79
80 /* Camera / view parameters (same conventions as BRL-CAD rt/grid.c) */
81 double viewrotscale[16]; /**< @brief Viewrotscale 4x4 matrix (row-major); [15] = 0.5*viewsize */
82 double eye_model[3]; /**< @brief eye position in model space (mm) */
83 double viewsize; /**< @brief view width in model units (mm) */
84 double aspect; /**< @brief pixel aspect ratio (width/height) */
85 double perspective; /**< @brief perspective half-angle in degrees; 0 = orthographic */
86};
87
88struct icv_image {
91 double *data;
95 struct icv_render_info *render_info; /**< @brief optional render metadata; NULL if not set */
96};
97
98
99typedef struct icv_image icv_image_t;
100#define ICV_IMAGE_NULL ((struct icv_image *)0)
101
102/**
103 * asserts the integrity of a icv_image_file struct.
104 */
105#define ICV_CK_IMAGE(_i) ICV_CKMAG(_i, ICV_IMAGE_MAGIC, "icv_image")
106
107/**
108 * initializes a icv_image_file struct without allocating any memory.
109 */
110#define ICV_IMAGE_INIT(_i) { \
111 (_i)->magic = ICV_IMAGE_MAGIC; \
112 (_i)->width = (_i)->height = (_i)->channels = (_i)->alpha_channel = 0; \
113 (_i)->gamma_corr = 0.0; \
114 (_i)->data = NULL; \
115 (_i)->flags = 0; \
116 (_i)->render_info = NULL; \
117 }
118
119/**
120 * returns truthfully whether a icv_image_file has been initialized.
121 */
122#define ICV_IMAGE_IS_INITIALIZED(_i) (((struct icv_image *)(_i) != ICV_IMAGE_NULL) && LIKELY((_i)->magic == ICV_IMAGE_MAGIC))
123
124/* Validation Macros */
125/**
126 * Validates input icv_struct, if failure (in validation) returns -1
127 */
128#define ICV_IMAGE_VAL_INT(_i) if (!ICV_IMAGE_IS_INITIALIZED(_i)) return -1
129
130/**
131 * Validates input icv_struct, if failure (in validation) returns NULL
132 */
133#define ICV_IMAGE_VAL_PTR(_i) if (!ICV_IMAGE_IS_INITIALIZED(_i)) return NULL
134
135
136/* Data conversion MACROS */
137/**
138 * Converts to double (icv data) type from unsigned char(8bit).
139 */
140#define ICV_CONV_8BIT(data) ((double)(data))/255.0
141
143
144/** @} */
145
146#endif /* ICV_DEFINES_H */
147
148/*
149 * Local Variables:
150 * tab-width: 8
151 * mode: C
152 * indent-tabs-mode: t
153 * c-file-style: "stroustrup"
154 * End:
155 * ex: shiftwidth=4 tabstop=8
156 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
ICV_COLOR_SPACE
Definition defines.h:50
ICV_DATA
Definition defines.h:56
@ ICV_COLOR_SPACE_GRAY
Definition defines.h:52
@ ICV_COLOR_SPACE_RGB
Definition defines.h:51
@ ICV_DATA_DOUBLE
Definition defines.h:57
@ ICV_DATA_UCHAR
Definition defines.h:58
size_t height
Definition defines.h:93
size_t width
Definition defines.h:93
struct icv_render_info * render_info
optional render metadata; NULL if not set
Definition defines.h:95
uint16_t flags
Definition defines.h:94
double * data
Definition defines.h:91
uint32_t magic
Definition defines.h:89
float gamma_corr
Definition defines.h:92
ICV_COLOR_SPACE color_space
Definition defines.h:90
size_t alpha_channel
Definition defines.h:93
size_t channels
Definition defines.h:93
double aspect
pixel aspect ratio (width/height)
Definition defines.h:84
double viewrotscale[16]
Viewrotscale 4x4 matrix (row-major); [15] = 0.5*viewsize.
Definition defines.h:81
char * db_filename
path to the .g geometry database
Definition defines.h:77
char * objects
space-separated list of top-level objects
Definition defines.h:78
double eye_model[3]
eye position in model space (mm)
Definition defines.h:82
double perspective
perspective half-angle in degrees; 0 = orthographic
Definition defines.h:85
double viewsize
view width in model units (mm)
Definition defines.h:83