BRL-CAD
Loading...
Searching...
No Matches
default.h
Go to the documentation of this file.
1
/* D E F A U L T . H
2
* BRL-CAD
3
*
4
* Copyright (c) 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 db_default
21
*
22
* @brief Deterministic default object selection for geometry databases.
23
*
24
*/
25
/** @{ */
26
/** @file rt/default.h */
27
28
#ifndef RT_DEFAULT_H
29
#define RT_DEFAULT_H
30
31
#include "
common.h
"
32
#include "
rt/defines.h
"
33
34
__BEGIN_DECLS
35
36
struct
bu_vls
;
37
struct
db_i
;
38
struct
directory
;
39
40
/**
41
* Default object attribute name stored on the v5 @c _GLOBAL object.
42
*/
43
#define DB_DEFAULT_OBJECT_ATTR "default_object"
44
45
/**
46
* Select a deterministic default geometry object for commands that can operate
47
* on one database object but were not given an explicit object name.
48
*
49
* The selection is intentionally conservative: a successful return means librt
50
* found exactly one geometry object according to the default-object rules. If
51
* the database disables default-object selection, if a rule has ambiguous
52
* matches, or if no rule matches, no object is selected and a printable
53
* explanation is written to @p msg when supplied.
54
*
55
* Selection order:
56
*
57
* 1. If the v5 @c _GLOBAL object has @c DB_DEFAULT_OBJECT_ATTR set to a
58
* non-empty, non-negative value, use that value as an exact object name.
59
* Empty/false/negative values disable automatic default-object selection.
60
* 2. If there is exactly one non-hidden top-level geometry object, select it.
61
* 3. If there is exactly one non-hidden combination in the database, select it.
62
* 4. If there is exactly one non-hidden combination whose name without its
63
* final extension matches the database filename without its final extension,
64
* select it.
65
* 5. If there is exactly one top-level non-hidden combination whose name
66
* case-insensitively matches @c all* or @c scene*, select it.
67
*
68
* @param[in] dbip
69
* Open database instance to inspect. The routine updates database reference
70
* counts with db_update_nref() before testing top-level status.
71
*
72
* @param[out] dp
73
* Optional output pointer. On successful selection, @c *dp is set to the
74
* selected directory pointer. On no selection or error, @c *dp is set to
75
* @c RT_DIR_NULL when @p dp is non-NULL.
76
*
77
* @param[in,out] msg
78
* Optional caller-owned, initialized @c bu_vls. On return 0 or -1,
79
* explanatory text is appended, including the available top-level objects when
80
* known. On successful selection, the routine leaves @p msg unchanged.
81
*
82
* @return 1 when a unique default object was selected.
83
* @return 0 when no object was selected because selection is disabled,
84
* ambiguous, or no deterministic match exists.
85
* @return -1 on internal failure.
86
*/
87
RT_EXPORT
extern
int
db_default_object
(
struct
db_i
*dbip,
88
struct
directory
**dp,
89
struct
bu_vls
*msg);
90
91
__END_DECLS
92
93
#endif
/* RT_DEFAULT_H */
94
/** @} */
95
96
/*
97
* Local Variables:
98
* tab-width: 8
99
* mode: C
100
* indent-tabs-mode: t
101
* c-file-style: "stroustrup"
102
* End:
103
* ex: shiftwidth=4 tabstop=8
104
*/
dvec
Definition
dvec.h:74
common.h
Header file for the BRL-CAD common definitions.
db_default_object
int db_default_object(struct db_i *dbip, struct directory **dp, struct bu_vls *msg)
defines.h
bu_vls
Definition
vls.h:53
db_i
Definition
db_instance.h:111
directory
Definition
directory.h:62
include
rt
default.h
Generated on Tue Jul 21 2026 02:18:11 for BRL-CAD by
1.9.8