MeshLib Documentation
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 <cassert>
8
9namespace MR
10{
11
14{
17 bool saveValidOnly = true;
18
21 bool rearrangeTriangles = true;
22
24 const VertColors * colors = nullptr;
25
27 const VertUVCoords * uvMap = nullptr;
28
30 const MeshTexture * texture = nullptr;
31
33 std::string materialName = "Default";
34
36 const AffineXf3d * xf = nullptr;
37
40};
41
43inline Vector3f applyFloat( const AffineXf3d * xf, const Vector3f & p )
44{
45 return xf ? Vector3f( (*xf)( Vector3d( p ) ) ) : p;
46}
47
49inline Vector3f applyFloat( const Matrix3d * m, const Vector3f & n )
50{
51 return m ? Vector3f( *m * Vector3d( n ) ) : n;
52}
53
55inline Vector3d applyDouble( const AffineXf3d * xf, const Vector3f & p )
56{
57 Vector3d pd( p );
58 return xf ? (*xf)( pd ) : pd;
59}
60
62inline Vector3d applyDouble( const Matrix3d * m, const Vector3f & n )
63{
64 Vector3d nd( n );
65 return m ? *m * nd : nd;
66}
67
70{
71public:
73 MRMESH_API VertRenumber( const VertBitSet & validVerts, bool saveValidOnly );
74
75 bool saveValidOnly() const { return !vert2packed_.empty(); }
76
78 int sizeVerts() const { return sizeVerts_; }
79
81 int operator()( VertId v ) const
82 {
83 assert( v );
84 return vert2packed_.empty() ? (int)v : vert2packed_[v];
85 }
86
87private:
88 Vector<int, VertId> vert2packed_;
89 int sizeVerts_ = 0;
90};
91
94MRMESH_API const VertCoords & transformPoints( const VertCoords & verts, const VertBitSet & validVerts, const AffineXf3d * xf, VertCoords & buf,
95 const VertRenumber * vertRenumber = nullptr );
96
99MRMESH_API const VertNormals & transformNormals( const VertNormals & normals, const VertBitSet & validVerts, const Matrix3d * m, VertNormals & buf );
100
101} //namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
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 MRSaveSettings.h:70
MRMESH_API VertRenumber(const VertBitSet &validVerts, bool saveValidOnly)
prepares the mapping
int sizeVerts() const
return the total number of vertices to be saved
Definition MRSaveSettings.h:78
int operator()(VertId v) const
return packed index (if saveValidOnly = true) or same index (if saveValidOnly = false)
Definition MRSaveSettings.h:81
bool saveValidOnly() const
Definition MRSaveSettings.h:75
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:576
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:43
Vector3d applyDouble(const AffineXf3d *xf, const Vector3f &p)
converts given point in double precision and applies given transformation to it
Definition MRSaveSettings.h:55
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 MRSaveSettings.h:14
bool saveValidOnly
Definition MRSaveSettings.h:17
const MeshTexture * texture
optional texture to save with the geometry
Definition MRSaveSettings.h:30
ProgressCallback progress
to report save progress and cancel saving if user desires
Definition MRSaveSettings.h:39
bool rearrangeTriangles
Definition MRSaveSettings.h:21
std::string materialName
used to save texture and material in some formats (obj)
Definition MRSaveSettings.h:33
const VertColors * colors
optional per-vertex color to save with the geometry
Definition MRSaveSettings.h:24
const VertUVCoords * uvMap
optional per-vertex uv coordinate to save with the geometry
Definition MRSaveSettings.h:27
const AffineXf3d * xf
this transformation can optionally be applied to all vertices (points) of saved object
Definition MRSaveSettings.h:36