OCCT-Light 0.1
C ABI and C++ veneer for multi-language CAD workflows
Loading...
Searching...
No Matches
io_ply.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
21#ifndef OCCTL_HPP_IO_PLY_HPP
22#define OCCTL_HPP_IO_PLY_HPP
23
24#include <occtl/occtl_io_ply.h>
25
26#include <occtl-hpp/core.hpp>
27#include <occtl-hpp/topo.hpp>
28
29#include <cstddef>
30#include <cstdint>
31#include <string>
32#include <vector>
33
34namespace occtl::io_ply
35{
36
44
47{
48 CoordinateSystem system_coordinate_system = CoordinateSystem::ZUp;
49 CoordinateSystem file_coordinate_system = CoordinateSystem::YUp;
50 bool write_normals = true;
51 bool write_colors = true;
52 bool write_texcoords = false;
53 bool write_part_id = true;
54 bool write_face_id = false;
55 std::string comment;
56 std::string author;
57
58 [[nodiscard]] ::occtl_io_ply_write_options_t to_c() const noexcept
59 {
60 ::occtl_io_ply_write_options_t aOpts = OCCTL_IO_PLY_WRITE_OPTIONS_INIT;
62 static_cast<::occtl_io_ply_coordinate_system_t>(system_coordinate_system);
64 static_cast<::occtl_io_ply_coordinate_system_t>(file_coordinate_system);
65 aOpts.write_normals = write_normals ? 1 : 0;
66 aOpts.write_colors = write_colors ? 1 : 0;
67 aOpts.write_texcoords = write_texcoords ? 1 : 0;
68 aOpts.write_part_id = write_part_id ? 1 : 0;
69 aOpts.write_face_id = write_face_id ? 1 : 0;
70 aOpts.comment = comment.empty() ? nullptr : comment.c_str();
71 aOpts.author = author.empty() ? nullptr : author.c_str();
72 return aOpts;
73 }
74};
75
78inline void write(const Graph& theGraph,
79 const NodeId theRoot,
80 const std::string& thePath,
81 const WriteOptions& theOptions = WriteOptions{})
82{
83 const ::occtl_io_ply_write_options_t aOpts = theOptions.to_c();
84 check(::occtl_io_ply_write(theGraph.get(), theRoot.get(), thePath.c_str(), &aOpts));
85}
86
87} // namespace occtl::io_ply
88
89#endif // OCCTL_HPP_IO_PLY_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
::occtl_node_id_t get() const noexcept
Borrows-it view of the underlying C value type, for direct ABI calls.
Definition topo.hpp:64
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
CoordinateSystem
Coordinate system used by PLY export conversion.
Definition io_ply.hpp:39
OCCT-Light: PLY file export.
occtl_status_t occtl_io_ply_write(const occtl_graph_t *graph, occtl_node_id_t root, const char *path, const occtl_io_ply_write_options_t *options)
enum occtl_io_ply_coordinate_system occtl_io_ply_coordinate_system_t
@ OCCTL_IO_PLY_COORDINATE_SYSTEM_GLTF
Definition occtl_io_ply.h:49
@ OCCTL_IO_PLY_COORDINATE_SYSTEM_Y_UP
Definition occtl_io_ply.h:47
@ OCCTL_IO_PLY_COORDINATE_SYSTEM_Z_UP
Definition occtl_io_ply.h:48
Options for write. PascalCase mirror of occtl_io_ply_write_options_t.
Definition io_ply.hpp:47
Definition occtl_io_ply.h:59
occtl_io_ply_coordinate_system_t system_coordinate_system
Definition occtl_io_ply.h:63
int32_t write_face_id
Definition occtl_io_ply.h:70
int32_t write_colors
Definition occtl_io_ply.h:67
int32_t write_normals
Definition occtl_io_ply.h:66
int32_t write_texcoords
Definition occtl_io_ply.h:68
const char * author
Definition occtl_io_ply.h:72
int32_t write_part_id
Definition occtl_io_ply.h:69
occtl_io_ply_coordinate_system_t file_coordinate_system
Definition occtl_io_ply.h:65
const char * comment
Definition occtl_io_ply.h:71
C++ veneer for the topo module.