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{
14
16struct SaveSettings
17{
20 bool onlyValidPoints = true;
21
27 bool packPrimitives = true;
28
30 const VertColors * colors = nullptr;
31
33 const std::vector<Color> * primitiveColors = nullptr;
34
36 const VertUVCoords * uvMap = nullptr;
37
40 bool saveTriCornerUVCoords = true;
41
43 const MeshTexture * texture = nullptr;
44
46 std::string materialName = "Default";
47
49 const AffineXf3d * xf = nullptr;
50
52 std::optional<LengthUnit> lengthUnit;
53
55 std::optional<Color> solidColor;
56
58 ProgressCallback progress;
59};
60
62inline Vector3f applyFloat( const AffineXf3d * xf, const Vector3f & p )
63{
64 return xf ? Vector3f( (*xf)( Vector3d( p ) ) ) : p;
65}
66
68inline Vector3f applyFloat( const Matrix3d * m, const Vector3f & n )
69{
70 return m ? Vector3f( *m * Vector3d( n ) ) : n;
71}
72
74inline Vector3d applyDouble( const AffineXf3d * xf, const Vector3f & p )
75{
76 Vector3d pd( p );
77 return xf ? (*xf)( pd ) : pd;
78}
79
81inline Vector3d applyDouble( const Matrix3d * m, const Vector3f & n )
82{
83 Vector3d nd( n );
84 return m ? *m * nd : nd;
85}
86
88class VertRenumber
89{
90public:
92 MRMESH_API VertRenumber( const VertBitSet & validVerts, bool saveValidOnly );
93
94 bool saveValidOnly() const { return !vert2packed_.empty(); }
95
97 int sizeVerts() const { return sizeVerts_; }
98
100 int operator()( VertId v ) const
101 {
102 assert( v );
103 return vert2packed_.empty() ? (int)v : vert2packed_[v];
104 }
105
106private:
107 Vector<int, VertId> vert2packed_;
108 int sizeVerts_ = 0;
109};
110
113MRMESH_API const VertCoords & transformPoints( const VertCoords & verts, const VertBitSet & validVerts, const AffineXf3d * xf, VertCoords & buf,
114 const VertRenumber * vertRenumber = nullptr );
115
118MRMESH_API const VertNormals & transformNormals( const VertNormals & normals, const VertBitSet & validVerts, const Matrix3d * m, VertNormals & buf );
119
120} //namespace MR
#define MRMESH_API
Definition MRMeshFwd.h:80
new unsafe ref bool onlyValidPoints
new unsafe MR.Std.Optional_MRLengthUnit lengthUnit
new unsafe MR.Std.? Const_Vector_MRColor primitiveColors
new unsafe MR.Std.Function_BoolFuncFromFloat progress
new unsafe MR.? Const_VertCoords2 uvMap
new unsafe MR.? ConstBox_AffineXf3d xf
new unsafe MR.Std.Optional_MRColor solidColor
new unsafe ref bool saveTriCornerUVCoords
new unsafe MR.? Const_MeshTexture texture
new unsafe MR.? Const_VertColors colors
new unsafe MR.Std.String materialName
new unsafe ref bool packPrimitives
Definition MRSaveSettings.h:89
unsafe VertRenumber(MR._ByValue_VertRenumber _other)
Definition MRCameraOrientationPlugin.h:8
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:62
Vector3d applyDouble(const AffineXf3d *xf, const Vector3f &p)
converts given point in double precision and applies given transformation to it
Definition MRSaveSettings.h:74
MRMESH_API const VertNormals & transformNormals(const VertNormals &normals, const VertBitSet &validVerts, const Matrix3d *m, VertNormals &buf)
MRMESH_API const VertCoords & transformPoints(const VertCoords &verts, const VertBitSet &validVerts, const AffineXf3d *xf, VertCoords &buf, const VertRenumber *vertRenumber=nullptr)