MeshLib C++ Docs
Loading...
Searching...
No Matches
MRSaveSettings.h
Go to the documentation of this file.
1#pragma once
2
4#include "MRAffineXf3.h"
5#include "MRId.h"
6#include "MRVector.h"
7#include "MRUnitInfo.h"
8#include "MRColor.h"
9#include <cassert>
10#include <optional>
11
12namespace MR
13{
16
17
20{
23 bool onlyValidPoints = true;
24
30 bool packPrimitives = true;
31
33 const VertColors * colors = nullptr;
34
36 const FaceColors * primitiveColors = nullptr;
37
39 const VertUVCoords * uvMap = nullptr;
40
44
46 const MeshTexture * texture = nullptr;
47
49 std::string materialName = "Default";
50
52 const AffineXf3d * xf = nullptr;
53
55 std::optional<LengthUnit> lengthUnit;
56
59 std::optional<Color> solidColor;
60
62 bool telemetrySignal = true;
63
66};
67
69inline Vector3f applyFloat( const AffineXf3d * xf, const Vector3f & p )
70{
71 return xf ? Vector3f( (*xf)( Vector3d( p ) ) ) : p;
72}
73
75inline Vector3f applyFloat( const Matrix3d * m, const Vector3f & n )
76{
77 return m ? Vector3f( *m * Vector3d( n ) ) : n;
78}
79
81inline Vector3d applyDouble( const AffineXf3d * xf, const Vector3f & p )
82{
83 Vector3d pd( p );
84 return xf ? (*xf)( pd ) : pd;
85}
86
88inline Vector3d applyDouble( const Matrix3d * m, const Vector3f & n )
89{
90 Vector3d nd( n );
91 return m ? *m * nd : nd;
92}
93
96{
97public:
99 MRMESH_API VertRenumber( const VertBitSet & validVerts, bool saveValidOnly );
100
101 bool saveValidOnly() const { return !vert2packed_.empty(); }
102
104 int sizeVerts() const { return sizeVerts_; }
105
107 int operator()( VertId v ) const
108 {
109 assert( v );
110 return vert2packed_.empty() ? (int)v : vert2packed_[v];
111 }
112
113private:
114 Vector<int, VertId> vert2packed_;
115 int sizeVerts_ = 0;
116};
117
120MRMESH_API const VertCoords & transformPoints( const VertCoords & verts, const VertBitSet & validVerts, const AffineXf3d * xf, VertCoords & buf,
121 const VertRenumber * vertRenumber = nullptr );
122
125MRMESH_API const VertNormals & transformNormals( const VertNormals & normals, const VertBitSet & validVerts, const Matrix3d * m, VertNormals & buf );
126
127}
#define MRMESH_API
Definition MRMeshFwd.h:85
Vector<T> is indexed by size_t.
Definition MRVector.h:24
maps valid points to packed sequential indices
Definition MRSaveSettings.h:96
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:790
const MeshTexture * texture
optional texture to save with the geometry
Definition MRSaveSettings.h:46
ProgressCallback progress
to report save progress and cancel saving if user desires
Definition MRSaveSettings.h:65
std::optional< Color > solidColor
Definition MRSaveSettings.h:59
int sizeVerts() const
return the total number of vertices to be saved
Definition MRSaveSettings.h:104
std::optional< LengthUnit > lengthUnit
units of input coordinates and transformation, to be serialized if the format supports it
Definition MRSaveSettings.h:55
VertRenumber(const VertBitSet &validVerts, bool saveValidOnly)
prepares the mapping
std::string materialName
the name of file (UTF8 encoded) without extension to save texture in some formats (e....
Definition MRSaveSettings.h:49
int operator()(VertId v) const
return packed index (if saveValidOnly = true) or same index (if saveValidOnly = false)
Definition MRSaveSettings.h:107
Vector3f applyFloat(const AffineXf3d *xf, const Vector3f &p)
returns the point as is or after application of given transform to it in double precision
Definition MRSaveSettings.h:69
const VertNormals & transformNormals(const VertNormals &normals, const VertBitSet &validVerts, const Matrix3d *m, VertNormals &buf)
bool saveValidOnly() const
Definition MRSaveSettings.h:101
bool telemetrySignal
permit telemetry signal about saving
Definition MRSaveSettings.h:62
const VertColors * colors
optional per-vertex color to save with the geometry
Definition MRSaveSettings.h:33
const VertUVCoords * uvMap
optional per-vertex uv coordinate to save with the geometry
Definition MRSaveSettings.h:39
Vector3d applyDouble(const AffineXf3d *xf, const Vector3f &p)
converts given point in double precision and applies given transformation to it
Definition MRSaveSettings.h:81
bool onlyValidPoints
Definition MRSaveSettings.h:23
const AffineXf3d * xf
this transformation can optionally be applied to all vertices (points) of saved object
Definition MRSaveSettings.h:52
const VertCoords & transformPoints(const VertCoords &verts, const VertBitSet &validVerts, const AffineXf3d *xf, VertCoords &buf, const VertRenumber *vertRenumber=nullptr)
bool saveTriCornerUVCoords
Definition MRSaveSettings.h:43
const FaceColors * primitiveColors
per-face colors for meshes, per-undirected-edge colors for polylines, unused for point clouds and oth...
Definition MRSaveSettings.h:36
bool packPrimitives
Definition MRSaveSettings.h:30
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRMeshTexture.h:13
determines how to save points/lines/mesh
Definition MRSaveSettings.h:20