MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMesh/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 <cassert>
8
9namespace MR
10{
11
14{
17 bool saveValidOnly = true;
18
24 bool rearrangeTriangles = true;
25
27 const VertColors * colors = nullptr;
28
30 const VertUVCoords * uvMap = nullptr;
31
33 const MeshTexture * texture = nullptr;
34
36 std::string materialName = "Default";
37
39 const AffineXf3d * xf = nullptr;
40
43};
44
46inline Vector3f applyFloat( const AffineXf3d * xf, const Vector3f & p )
47{
48 return xf ? Vector3f( (*xf)( Vector3d( p ) ) ) : p;
49}
50
52inline Vector3f applyFloat( const Matrix3d * m, const Vector3f & n )
53{
54 return m ? Vector3f( *m * Vector3d( n ) ) : n;
55}
56
58inline Vector3d applyDouble( const AffineXf3d * xf, const Vector3f & p )
59{
60 Vector3d pd( p );
61 return xf ? (*xf)( pd ) : pd;
62}
63
65inline Vector3d applyDouble( const Matrix3d * m, const Vector3f & n )
66{
67 Vector3d nd( n );
68 return m ? *m * nd : nd;
69}
70
73{
74public:
76 MRMESH_API VertRenumber( const VertBitSet & validVerts, bool saveValidOnly );
77
78 bool saveValidOnly() const { return !vert2packed_.empty(); }
79
81 int sizeVerts() const { return sizeVerts_; }
82
84 int operator()( VertId v ) const
85 {
86 assert( v );
87 return vert2packed_.empty() ? (int)v : vert2packed_[v];
88 }
89
90private:
91 Vector<int, VertId> vert2packed_;
92 int sizeVerts_ = 0;
93};
94
97MRMESH_API const VertCoords & transformPoints( const VertCoords & verts, const VertBitSet & validVerts, const AffineXf3d * xf, VertCoords & buf,
98 const VertRenumber * vertRenumber = nullptr );
99
102MRMESH_API const VertNormals & transformNormals( const VertNormals & normals, const VertBitSet & validVerts, const Matrix3d * m, VertNormals & buf );
103
104} //namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:20
bool empty() const
Definition MRMesh/MRVector.h:40
maps valid points to packed sequential indices
Definition MRMesh/MRSaveSettings.h:73
MRMESH_API VertRenumber(const VertBitSet &validVerts, bool saveValidOnly)
prepares the mapping
int sizeVerts() const
return the total number of vertices to be saved
Definition MRMesh/MRSaveSettings.h:81
int operator()(VertId v) const
return packed index (if saveValidOnly = true) or same index (if saveValidOnly = false)
Definition MRMesh/MRSaveSettings.h:84
bool saveValidOnly() const
Definition MRMesh/MRSaveSettings.h:78
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:626
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 MRMesh/MRSaveSettings.h:46
Vector3d applyDouble(const AffineXf3d *xf, const Vector3f &p)
converts given point in double precision and applies given transformation to it
Definition MRMesh/MRSaveSettings.h:58
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)
Definition MRMeshTexture.h:13
determines how to save points/lines/mesh
Definition MRMesh/MRSaveSettings.h:14
bool saveValidOnly
Definition MRMesh/MRSaveSettings.h:17
const MeshTexture * texture
optional texture to save with the geometry
Definition MRMesh/MRSaveSettings.h:33
ProgressCallback progress
to report save progress and cancel saving if user desires
Definition MRMesh/MRSaveSettings.h:42
bool rearrangeTriangles
Definition MRMesh/MRSaveSettings.h:24
std::string materialName
used to save texture and material in some formats (obj)
Definition MRMesh/MRSaveSettings.h:36
const VertColors * colors
optional per-vertex color to save with the geometry
Definition MRMesh/MRSaveSettings.h:27
const VertUVCoords * uvMap
optional per-vertex uv coordinate to save with the geometry
Definition MRMesh/MRSaveSettings.h:30
const AffineXf3d * xf
this transformation can optionally be applied to all vertices (points) of saved object
Definition MRMesh/MRSaveSettings.h:39