OCCT-Light 0.1
C ABI and C++ veneer for multi-language CAD workflows
Loading...
Searching...
No Matches
bool.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Capgemini Engineering Research and Development.
2//
3// This file is part of OCCT-Light software library.
4//
5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Affero General Public License version 3 as published
7// by the Free Software Foundation, with an option to use any later version.
8// Consult the file LICENSE_AGPL_30.txt included in OCCT-Light distribution
9// for complete text of the license and disclaimer of any warranty.
10//
11// Alternatively, this file may be used under the terms of a commercial
12// license or contractual agreement.
13//
14// SPDX-License-Identifier: AGPL-3.0-or-later
15
25#ifndef OCCTL_HPP_BOOL_HPP
26#define OCCTL_HPP_BOOL_HPP
27
28#include <occtl/occtl_bool.h>
29
30#include <occtl-hpp/core.hpp>
31#include <occtl-hpp/topo.hpp>
32
33#include <cstddef>
34#include <cstdint>
35#include <vector>
36
39namespace occtl::bool_
40{
41
44{
45 double fuzzy_value = 0.0;
46 bool run_parallel = false;
47 bool simplify_result = false;
48 double simplify_angular_tolerance = 1.0e-2;
49 bool build_history = true;
50
52 [[nodiscard]] ::occtl_bool_options_t to_c() const noexcept
53 {
55 aOpts.fuzzy_value = fuzzy_value;
56 aOpts.run_parallel = run_parallel ? 1 : 0;
57 aOpts.simplify_result = simplify_result ? 1 : 0;
58 aOpts.simplify_angular_tolerance = simplify_angular_tolerance;
59 aOpts.build_history = build_history ? 1 : 0;
60 return aOpts;
61 }
62};
63
64namespace detail
65{
66using EntryFn = ::occtl_status_t (*)(::occtl_graph_t*,
67 const ::occtl_node_id_t*,
68 std::size_t,
69 const ::occtl_node_id_t*,
70 std::size_t,
71 const ::occtl_bool_options_t*,
73
74inline NodeId run(const EntryFn theFn,
75 Graph& theGraph,
76 const std::vector<NodeId>& theObjects,
77 const std::vector<NodeId>& theTools,
78 const BoolOptions& theOpts)
79{
80 std::vector<::occtl_node_id_t> aObjIds;
81 aObjIds.reserve(theObjects.size());
82 for (const NodeId& aId : theObjects)
83 {
84 aObjIds.emplace_back(aId.get());
85 }
86
87 std::vector<::occtl_node_id_t> aToolIds;
88 aToolIds.reserve(theTools.size());
89 for (const NodeId& aId : theTools)
90 {
91 aToolIds.emplace_back(aId.get());
92 }
93
94 ::occtl_bool_options_t aOpts = theOpts.to_c();
96
97 check(theFn(theGraph.get(),
98 aObjIds.empty() ? nullptr : aObjIds.data(),
99 aObjIds.size(),
100 aToolIds.empty() ? nullptr : aToolIds.data(),
101 aToolIds.size(),
102 &aOpts,
103 &aRoot));
104
105 return NodeId(aRoot);
106}
107} // namespace detail
108
110inline NodeId fuse(Graph& theGraph,
111 const std::vector<NodeId>& theObjects,
112 const std::vector<NodeId>& theTools,
113 const BoolOptions& theOpts = {})
114{
115 return detail::run(&::occtl_bool_fuse, theGraph, theObjects, theTools, theOpts);
116}
117
119inline NodeId cut(Graph& theGraph,
120 const std::vector<NodeId>& theObjects,
121 const std::vector<NodeId>& theTools,
122 const BoolOptions& theOpts = {})
123{
124 return detail::run(&::occtl_bool_cut, theGraph, theObjects, theTools, theOpts);
125}
126
128inline NodeId common(Graph& theGraph,
129 const std::vector<NodeId>& theObjects,
130 const std::vector<NodeId>& theTools,
131 const BoolOptions& theOpts = {})
132{
133 return detail::run(&::occtl_bool_common, theGraph, theObjects, theTools, theOpts);
134}
135
137inline NodeId section(Graph& theGraph,
138 const std::vector<NodeId>& theObjects,
139 const std::vector<NodeId>& theTools,
140 const BoolOptions& theOpts = {})
141{
142 return detail::run(&::occtl_bool_section, theGraph, theObjects, theTools, theOpts);
143}
144
146inline NodeId split(Graph& theGraph,
147 const std::vector<NodeId>& theObjects,
148 const std::vector<NodeId>& theTools,
149 const BoolOptions& theOpts = {})
150{
151 return detail::run(&::occtl_bool_split, theGraph, theObjects, theTools, theOpts);
152}
153
154} // namespace occtl::bool_
155
156#endif // OCCTL_HPP_BOOL_HPP
RAII handle for a topology graph. Mirrors occtl_graph_t.
Definition topo.hpp:1444
::occtl_graph_t * get() const noexcept
Borrows-it pointer to the underlying C handle, for direct ABI calls.
Definition topo.hpp:1494
Session-local identity of a graph node. Mirrors occtl_node_id_t.
Definition topo.hpp:52
C++ veneer for the core module.
void check(const ::occtl_status_t theStatus)
Throw on non-OK; otherwise a no-op.
Definition core.hpp:85
Boolean-operation veneer namespace; trailing underscore avoids the C++ keyword.
NodeId cut(Graph &theGraph, const std::vector< NodeId > &theObjects, const std::vector< NodeId > &theTools, const BoolOptions &theOpts={})
Boolean Cut. See occtl_bool_cut.
Definition bool.hpp:119
NodeId section(Graph &theGraph, const std::vector< NodeId > &theObjects, const std::vector< NodeId > &theTools, const BoolOptions &theOpts={})
Boolean Section. See occtl_bool_section.
Definition bool.hpp:137
NodeId common(Graph &theGraph, const std::vector< NodeId > &theObjects, const std::vector< NodeId > &theTools, const BoolOptions &theOpts={})
Boolean Common (intersection). See occtl_bool_common.
Definition bool.hpp:128
NodeId fuse(Graph &theGraph, const std::vector< NodeId > &theObjects, const std::vector< NodeId > &theTools, const BoolOptions &theOpts={})
Boolean Fuse of two argument groups. See occtl_bool_fuse.
Definition bool.hpp:110
NodeId split(Graph &theGraph, const std::vector< NodeId > &theObjects, const std::vector< NodeId > &theTools, const BoolOptions &theOpts={})
Boolean Split. See occtl_bool_split.
Definition bool.hpp:146
OCCT-Light: boolean operations module public API.
occtl_status_t occtl_bool_common(occtl_graph_t *graph, const occtl_node_id_t *objects, size_t n_objects, const occtl_node_id_t *tools, size_t n_tools, const occtl_bool_options_t *opts, occtl_node_id_t *out_root)
occtl_status_t occtl_bool_fuse(occtl_graph_t *graph, const occtl_node_id_t *objects, size_t n_objects, const occtl_node_id_t *tools, size_t n_tools, const occtl_bool_options_t *opts, occtl_node_id_t *out_root)
occtl_status_t occtl_bool_split(occtl_graph_t *graph, const occtl_node_id_t *objects, size_t n_objects, const occtl_node_id_t *tools, size_t n_tools, const occtl_bool_options_t *opts, occtl_node_id_t *out_root)
occtl_status_t occtl_bool_cut(occtl_graph_t *graph, const occtl_node_id_t *objects, size_t n_objects, const occtl_node_id_t *tools, size_t n_tools, const occtl_bool_options_t *opts, occtl_node_id_t *out_root)
#define OCCTL_BOOL_OPTIONS_INIT
Definition occtl_bool.h:82
occtl_status_t occtl_bool_section(occtl_graph_t *graph, const occtl_node_id_t *objects, size_t n_objects, const occtl_node_id_t *tools, size_t n_tools, const occtl_bool_options_t *opts, occtl_node_id_t *out_root)
enum occtl_status occtl_status_t
#define OCCTL_NODE_ID_INVALID
Definition occtl_topo_types.h:138
struct occtl_graph occtl_graph_t
Definition occtl_topo_types.h:152
PascalCase mirror of occtl_bool_options_t with idiomatic defaults.
Definition bool.hpp:44
::occtl_bool_options_t to_c() const noexcept
Project into the C ABI options struct.
Definition bool.hpp:52
Definition occtl_bool.h:67
int32_t simplify_result
Definition occtl_bool.h:72
double simplify_angular_tolerance
Definition occtl_bool.h:73
int32_t run_parallel
Definition occtl_bool.h:71
int32_t build_history
Definition occtl_bool.h:75
double fuzzy_value
Definition occtl_bool.h:70
Definition occtl_topo_types.h:50
C++ veneer for the topo module.