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 "MRUnitInfo.h"
8#include "MRColor.h"
9#include <cassert>
10#include <optional>
11
12namespace MR
13{
14
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
39 const MeshTexture * texture = nullptr;
40
42 std::string materialName = "Default";
43
45 const AffineXf3d * xf = nullptr;
46
48 std::optional<LengthUnit> lengthUnit;
49
51 std::optional<Color> solidColor;
52
55};
56
58inline Vector3f applyFloat( const AffineXf3d * xf, const Vector3f & p )
59{
60 return xf ? Vector3f( (*xf)( Vector3d( p ) ) ) : p;
61}
62
64inline Vector3f applyFloat( const Matrix3d * m, const Vector3f & n )
65{
66 return m ? Vector3f( *m * Vector3d( n ) ) : n;
67}
68
70inline Vector3d applyDouble( const AffineXf3d * xf, const Vector3f & p )
71{
72 Vector3d pd( p );
73 return xf ? (*xf)( pd ) : pd;
74}
75
77inline Vector3d applyDouble( const Matrix3d * m, const Vector3f & n )
78{
79 Vector3d nd( n );
80 return m ? *m * nd : nd;
81}
82
85{
86public:
88 MRMESH_API VertRenumber( const VertBitSet & validVerts, bool saveValidOnly );
89
90 bool saveValidOnly() const { return !vert2packed_.empty(); }
91
93 int sizeVerts() const { return sizeVerts_; }
94
96 int operator()( VertId v ) const
97 {
98 assert( v );
99 return vert2packed_.empty() ? (int)v : vert2packed_[v];
100 }
101
102private:
103 Vector<int, VertId> vert2packed_;
104 int sizeVerts_ = 0;
105};
106
109MRMESH_API const VertCoords & transformPoints( const VertCoords & verts, const VertBitSet & validVerts, const AffineXf3d * xf, VertCoords & buf,
110 const VertRenumber * vertRenumber = nullptr );
111
114MRMESH_API const VertNormals & transformNormals( const VertNormals & normals, const VertBitSet & validVerts, const Matrix3d * m, VertNormals & buf );
115
116} //namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:19
bool empty() const
Definition MRMesh/MRVector.h:49
maps valid points to packed sequential indices
Definition MRMesh/MRSaveSettings.h:85
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:93
int operator()(VertId v) const
return packed index (if saveValidOnly = true) or same index (if saveValidOnly = false)
Definition MRMesh/MRSaveSettings.h:96
bool saveValidOnly() const
Definition MRMesh/MRSaveSettings.h:90
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:732
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 MRMesh/MRSaveSettings.h:58
Vector3d applyDouble(const AffineXf3d *xf, const Vector3f &p)
converts given point in double precision and applies given transformation to it
Definition MRMesh/MRSaveSettings.h:70
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:17
const MeshTexture * texture
optional texture to save with the geometry
Definition MRMesh/MRSaveSettings.h:39
ProgressCallback progress
to report save progress and cancel saving if user desires
Definition MRMesh/MRSaveSettings.h:54
std::optional< Color > solidColor
the color of whole object
Definition MRMesh/MRSaveSettings.h:51
std::optional< LengthUnit > lengthUnit
units of input coordinates and transformation, to be serialized if the format supports it
Definition MRMesh/MRSaveSettings.h:48
const std::vector< Color > * primitiveColors
per-face colors for meshes, per-undirected-edge colors for polylines, unused for point clouds and oth...
Definition MRMesh/MRSaveSettings.h:33
std::string materialName
used to save texture and material in some formats (obj)
Definition MRMesh/MRSaveSettings.h:42
const VertColors * colors
optional per-vertex color to save with the geometry
Definition MRMesh/MRSaveSettings.h:30
const VertUVCoords * uvMap
optional per-vertex uv coordinate to save with the geometry
Definition MRMesh/MRSaveSettings.h:36
bool onlyValidPoints
Definition MRMesh/MRSaveSettings.h:20
const AffineXf3d * xf
this transformation can optionally be applied to all vertices (points) of saved object
Definition MRMesh/MRSaveSettings.h:45
bool packPrimitives
Definition MRMesh/MRSaveSettings.h:27