3#include "MRPch/MRBindingMacros.h"
39 constexpr static const
char* TypeName() noexcept {
return "MeshHolder"; }
40 virtual const char*
typeName()
const override {
return TypeName(); }
47 [[nodiscard]]
virtual bool hasModel()
const override {
return bool( data_.mesh ); }
50 #pragma GCC diagnostic push
51 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
53 const std::shared_ptr< const Mesh >&
mesh()
const
54 {
return reinterpret_cast< const std::shared_ptr<const Mesh>&
>( data_.mesh ); }
56 #pragma GCC diagnostic pop
60 MeshPart
meshPart()
const {
return data_.selectedFaces.any() ? MeshPart{ *data_.mesh, &data_.selectedFaces } : *data_.mesh; }
94 const UndirectedEdgeBitSet&
creases()
const {
return data_.creases; }
99 {
return setVisualizeProperty( on, MeshVisualizePropertyType::FlatShading, ViewportMask::all() ); }
101 {
return getVisualizeProperty( MeshVisualizePropertyType::FlatShading, ViewportMask::any() ); }
139 { edgesColor_.set( color,
id ); needRedraw_ =
true; }
143 { pointsColor_.set( color,
id ); needRedraw_ =
true; }
147 { bordersColor_.set( color,
id ); needRedraw_ =
true; }
169 const VertUVCoords&
getUVCoords()
const {
return data_.uvCoordinates; }
170 virtual void setUVCoords( VertUVCoords uvCoordinates ) { data_.uvCoordinates = std::move( uvCoordinates ); setDirtyFlags(
DIRTY_UV ); }
171 virtual void updateUVCoords( VertUVCoords& updated ) { std::swap( data_.uvCoordinates, updated ); setDirtyFlags(
DIRTY_UV ); }
187 bool hasAncillaryTexture()
const {
return !ancillaryUVCoordinates_.empty() && !ancillaryTexture_.pixels.empty(); }
324 float edgeWidth_{ 0.5f };
325 float pointSize_{ 5.f };
329 void setDefaultColors_();
332 void setDefaultSceneProperties_();
334 const char * serializeFormat_ =
nullptr;
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:84
Points
Definition MRObjectLinesHolder.h:10
OnlyOddFragments
Definition MRObjectMeshHolder.h:22
Faces
Definition MRObjectMeshHolder.h:14
SelectedFaces
Definition MRObjectMeshHolder.h:18
Edges
Definition MRObjectMeshHolder.h:16
EnableShading
Definition MRObjectMeshHolder.h:20
PolygonOffsetFromCamera
Definition MRObjectMeshHolder.h:24
FlatShading
Definition MRObjectMeshHolder.h:21
SelectedEdges
Definition MRObjectMeshHolder.h:19
Texture
Definition MRObjectMeshHolder.h:15
BordersHighlight
Definition MRObjectMeshHolder.h:23
Definition MRVisualObject.h:57
Definition MRObjectMeshHolder.h:32
Vector< MeshTexture, TextureId > textures_
Texture options.
Definition MRObjectMeshHolder.h:263
virtual MRMESH_API void copyColors(const ObjectMeshHolder &src, const VertMap &thisToSrc, const FaceMap &thisToSrcFaces={})
copies vertex colors from given source object
virtual void updateTexturePerFace(Vector< TextureId, FaceId > &texturePerFace)
Definition MRObjectMeshHolder.h:165
MRMESH_API size_t numUndirectedEdges() const
returns cached information about the number of undirected edges in the mesh
MRMESH_API const Color & getSelectedFacesColor(ViewportId id={}) const
returns colors of selected triangles
ViewportProperty< Color > faceSelectionColor_
Definition MRObjectMeshHolder.h:322
virtual void updateTextures(Vector< MeshTexture, TextureId > &updated)
Definition MRObjectMeshHolder.h:160
MRMESH_API AllVisualizeProperties getAllVisualizeProperties() const override
get all visualize properties masks
const Color & getEdgesColor(ViewportId id={}) const
Definition MRObjectMeshHolder.h:137
virtual MRMESH_API void setupRenderObject_() const override
const FaceColors & getFacesColorMap() const
Definition MRObjectMeshHolder.h:128
virtual bool hasModel() const override
Definition MRObjectMeshHolder.h:47
SelectionChangedSignal edgeSelectionChangedSignal
Definition MRObjectMeshHolder.h:256
MRMESH_API virtual MR_BIND_IGNORE void setTexture(MeshTexture texture)
const VertUVCoords & getUVCoords() const
Definition MRObjectMeshHolder.h:169
virtual void setTexturePerFace(Vector< TextureId, FaceId > texturePerFace)
Definition MRObjectMeshHolder.h:164
virtual MRMESH_API void setEdgeWidth(float edgeWidth)
MRMESH_API void deserializeFields_(const Json::Value &root) override
std::optional< size_t > numHoles_
Definition MRObjectMeshHolder.h:268
ViewportProperty< Color > edgeSelectionColor_
Definition MRObjectMeshHolder.h:321
virtual void addTexture(MeshTexture texture)
Definition MRObjectMeshHolder.h:166
ViewportMask flatShading_
toggle per-face or per-vertex properties
Definition MRObjectMeshHolder.h:310
virtual MRMESH_API void setDirtyFlags(uint32_t mask, bool invalidateCaches=true) override
MRMESH_API uint32_t getNeededNormalsRenderDirtyValue(ViewportMask viewportMask) const
returns dirty flag of currently using normal type if they are dirty in render representation
const Vector< MeshTexture, TextureId > & getTextures() const
Definition MRObjectMeshHolder.h:158
ViewportMask showEdges_
Definition MRObjectMeshHolder.h:304
ObjectMeshHolder(ProtectedStruct, const ObjectMeshHolder &obj)
Definition MRObjectMeshHolder.h:150
const Color & getBordersColor(ViewportId id={}) const
Definition MRObjectMeshHolder.h:145
virtual MRMESH_API Box3f getWorldBox(ViewportId={}) const override
MRMESH_API double totalArea() const
returns cached summed area of mesh triangles
ViewportProperty< XfBasedCache< Box3f > > worldBox_
Definition MRObjectMeshHolder.h:277
virtual MRMESH_API void setCreases(UndirectedEdgeBitSet creases)
virtual void setEdgesColor(const Color &color, ViewportId id={})
Definition MRObjectMeshHolder.h:138
virtual void setVertsColorMap(VertColors vertsColorMap)
sets per-vertex colors of the object
Definition MRObjectMeshHolder.h:123
ViewportMask onlyOddFragments_
Definition MRObjectMeshHolder.h:316
virtual void updateVertsColorMap(VertColors &vertsColorMap)
swaps per-vertex colors of the object with given argument
Definition MRObjectMeshHolder.h:126
VertUVCoords ancillaryUVCoordinates_
vertices coordinates in ancillary texture
Definition MRObjectMeshHolder.h:266
MRMESH_API void setAllVisualizeProperties_(const AllVisualizeProperties &properties, std::size_t &pos) override
set all visualize properties masks
MRMESH_API const ViewportProperty< Color > & getBordersColorsForAllViewports() const
virtual void updateUVCoords(VertUVCoords &updated)
Definition MRObjectMeshHolder.h:171
virtual MRMESH_API void setPointSize(float size)
SelectionChangedSignal faceSelectionChangedSignal
Definition MRObjectMeshHolder.h:255
ObjectMeshHolder(ObjectMeshHolder &&) noexcept=default
virtual MRMESH_API void setSelectedFacesColorsForAllViewports(ViewportProperty< Color > val)
ObjectMeshData data_
Definition MRObjectMeshHolder.h:260
ViewportMask showPoints_
Definition MRObjectMeshHolder.h:305
virtual MRMESH_API bool hasVisualRepresentation() const override
mesh object can be seen if the mesh has at least one edge
MRMESH_API const ViewportProperty< Color > & getSelectedEdgesColorsForAllViewports() const
virtual MRMESH_API void setSelectedEdgesColorsForAllViewports(ViewportProperty< Color > val)
std::optional< double > volume_
Definition MRObjectMeshHolder.h:275
MRMESH_API virtual MR_BIND_IGNORE void updateTexture(MeshTexture &updated)
virtual MRMESH_API std::shared_ptr< Object > shallowClone() const override
virtual MRMESH_API size_t heapBytes() const override
returns the amount of memory this object occupies on heap
const TexturePerFace & getTexturePerFace() const
Definition MRObjectMeshHolder.h:167
MeshPart meshPart() const
Definition MRObjectMeshHolder.h:60
const MeshTexture & getAncillaryTexture() const
Definition MRObjectMeshHolder.h:180
std::optional< size_t > numHandles_
Definition MRObjectMeshHolder.h:271
MRMESH_API size_t numCreaseEdges() const
returns cached information about the number of crease undirected edges in the mesh
void updateAncillaryUVCoords(VertUVCoords &updated)
Definition MRObjectMeshHolder.h:185
const FaceBitSet & getSelectedFaces() const
Definition MRObjectMeshHolder.h:67
bool hasAncillaryTexture() const
Definition MRObjectMeshHolder.h:187
std::optional< size_t > numUndirectedEdges_
Definition MRObjectMeshHolder.h:270
ViewportProperty< Color > pointsColor_
Definition MRObjectMeshHolder.h:319
virtual MRMESH_API void selectEdges(UndirectedEdgeBitSet newSelection)
MRMESH_API const char * actualSerializeFormat() const
returns overriden file extension used to serialize mesh inside this object if set,...
void setFlatShading(bool on)
sets flat (true) or smooth (false) shading
Definition MRObjectMeshHolder.h:98
MRMESH_API const MeshTexture & getTexture() const
returns first texture in the vector. If there is no textures, returns empty texture
const UndirectedEdgeBitSet & getSelectedEdges() const
Definition MRObjectMeshHolder.h:74
std::optional< float > avgEdgeLen_
Definition MRObjectMeshHolder.h:276
virtual void setPointsColor(const Color &color, ViewportId id={})
Definition MRObjectMeshHolder.h:142
ViewportMask showBordersHighlight_
Definition MRObjectMeshHolder.h:308
virtual const char * typeName() const override
Definition MRObjectMeshHolder.h:40
ObjectMeshHolder(const ObjectMeshHolder &other)=default
MRMESH_API double volume() const
returns cached volume of space surrounded by the mesh, which is valid only if mesh is closed
MRMESH_API void setSerializeFormat(const char *newFormat)
virtual MRMESH_API void serializeFields_(Json::Value &root) const override
std::optional< size_t > numComponents_
Definition MRObjectMeshHolder.h:269
virtual MRMESH_API void setSelectedEdgesColor(const Color &color, ViewportId id={})
sets colors of selected edges
virtual MRMESH_API void selectFaces(FaceBitSet newSelection)
virtual void setTextures(Vector< MeshTexture, TextureId > texture)
Definition MRObjectMeshHolder.h:159
virtual MRMESH_API Expected< std::future< Expected< void > > > serializeModel_(const std::filesystem::path &path) const override
virtual MRMESH_API Box3f computeBoundingBox_() const override
virtual MRMESH_API bool getRedrawFlag(ViewportMask viewportMask) const override
returns true if the object must be redrawn (due to dirty flags) in one of specified viewports
const VertUVCoords & getAncillaryUVCoords() const
Definition MRObjectMeshHolder.h:183
virtual MRMESH_API void setBordersColorsForAllViewports(ViewportProperty< Color > val)
virtual void setAncillaryUVCoords(VertUVCoords uvCoordinates)
Definition MRObjectMeshHolder.h:184
MRMESH_API const Color & getSelectedEdgesColor(ViewportId id={}) const
returns colors of selected edges
MRMESH_API float avgEdgeLen() const
returns cached average edge length
MRMESH_API size_t numHoles() const
returns cached information about the number of holes in the mesh
MeshTexture ancillaryTexture_
Definition MRObjectMeshHolder.h:265
bool flatShading() const
Definition MRObjectMeshHolder.h:100
MRMESH_API void clearAncillaryTexture()
virtual float getPointSize() const
Definition MRObjectMeshHolder.h:135
const char * serializeFormat() const
returns overriden file extension used to serialize mesh inside this object, nullptr means defaultSeri...
Definition MRObjectMeshHolder.h:239
const UndirectedEdgeBitSet & creases() const
Edges on mesh, that will have sharp visualization even with smooth shading.
Definition MRObjectMeshHolder.h:94
MRMESH_API void resetColors() override
reset all object colors to their default values from the current theme
MRMESH_API void resetFrontColor() override
reset basic object colors to their default values from the current theme
virtual void setUVCoords(VertUVCoords uvCoordinates)
Definition MRObjectMeshHolder.h:170
virtual void setBordersColor(const Color &color, ViewportId id={})
Definition MRObjectMeshHolder.h:146
virtual MRMESH_API void swapBase_(Object &other) override
swaps this object with other
virtual void updateData(ObjectMeshData &data)
swaps whole ObjectMeshData with given argument
Definition MRObjectMeshHolder.h:117
ViewportProperty< Color > bordersColor_
Definition MRObjectMeshHolder.h:320
virtual MRMESH_API void setEdgesColorsForAllViewports(ViewportProperty< Color > val)
ViewportMask polygonOffset_
Definition MRObjectMeshHolder.h:309
MRMESH_API size_t numSelectedEdges() const
returns cached information about the number of selected undirected edges in the mesh
virtual MRMESH_API void swapSignals_(Object &other) override
MRMESH_API size_t numSelectedFaces() const
returns cached information about the number of selected faces in the mesh
const Color & getPointsColor(ViewportId id={}) const
Definition MRObjectMeshHolder.h:141
std::optional< double > selectedArea_
Definition MRObjectMeshHolder.h:274
const VertColors & getVertsColorMap() const
returns per-vertex colors of the object
Definition MRObjectMeshHolder.h:120
MRMESH_API const ViewportMask & getVisualizePropertyMask(AnyVisualizeMaskEnum type) const override
returns mask of viewports where given property is set
MRMESH_API const ViewportProperty< Color > & getEdgesColorsForAllViewports() const
virtual MRMESH_API void copyTextureAndColors(const ObjectMeshHolder &src, const VertMap &thisToSrc, const FaceMap &thisToSrcFaces={})
copies texture, UV-coordinates and vertex colors from given source object
virtual void setFacesColorMap(FaceColors facesColorMap)
Definition MRObjectMeshHolder.h:129
virtual void setData(ObjectMeshData &&data)
sets whole new ObjectMeshData
Definition MRObjectMeshHolder.h:114
float getEdgeWidth() const
Definition MRObjectMeshHolder.h:133
std::optional< bool > meshIsClosed_
Definition MRObjectMeshHolder.h:272
MRMESH_API bool isMeshClosed() const
returns cached information whether the mesh is closed
MRMESH_API const ViewportProperty< Color > & getSelectedFacesColorsForAllViewports() const
const ObjectMeshData & data() const
provides read-only access to whole ObjectMeshData
Definition MRObjectMeshHolder.h:111
MRMESH_API size_t numHandles() const
returns cached information about the number of handles in the mesh
virtual MRMESH_API void setSelectedFacesColor(const Color &color, ViewportId id={})
sets colors of selected triangles
MRMESH_API size_t numComponents() const
returns cached information about the number of components in the mesh
virtual MRMESH_API std::shared_ptr< Object > clone() const override
MRMESH_API bool supportsVisualizeProperty(AnyVisualizeMaskEnum type) const override
Returns true if this class supports the property type. Otherwise passing it to the functions below is...
MRMESH_API Expected< void > deserializeModel_(const std::filesystem::path &path, ProgressCallback progressCb={}) override
Reads model from file.
std::optional< size_t > numCreaseEdges_
Definition MRObjectMeshHolder.h:273
const std::shared_ptr< const Mesh > & mesh() const
Definition MRObjectMeshHolder.h:53
ViewportMask showTexture_
Definition MRObjectMeshHolder.h:302
SelectionChangedSignal creasesChangedSignal
Definition MRObjectMeshHolder.h:257
virtual void setAncillaryTexture(MeshTexture texture)
Definition MRObjectMeshHolder.h:181
MRMESH_API double selectedArea() const
returns cached area of selected triangles
virtual void updateFacesColorMap(FaceColors &updated)
Definition MRObjectMeshHolder.h:130
ViewportProperty< Color > edgesColor_
Definition MRObjectMeshHolder.h:318
virtual MRMESH_API void applyScale(float scaleFactor) override
scale object size (all point positions)
MRMESH_API ObjectMeshHolder()
named object in the data model
Definition MRObject.h:62
std::vector<T>-like container that requires specific indexing type,
Definition MRMesh/MRVector.h:19
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:42
Definition MRViewportProperty.h:17
Visual Object.
Definition MRVisualObject.h:122
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:728
std::vector< ViewportMask > AllVisualizeProperties
Definition MRVisualObject.h:75
@ DIRTY_PRIMITIVE_COLORMAP
Definition MRVisualObject.h:91
@ DIRTY_TEXTURE
Definition MRVisualObject.h:87
@ DIRTY_TEXTURE_PER_FACE
Definition MRVisualObject.h:93
@ DIRTY_VERTS_COLORMAP
Definition MRVisualObject.h:90
@ DIRTY_ALL
Definition MRVisualObject.h:100
@ DIRTY_UV
Definition MRVisualObject.h:81
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:25
MRMESH_API void setDefaultSerializeMeshFormat(std::string newFormat)
MRMESH_API const std::string & defaultSerializeMeshFormat()
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:10
Definition MRMesh/MRColor.h:9
Definition MRVisualObject.h:35
Definition MRMeshTexture.h:13
mesh and its per-element attributes for ObjectMeshHolder
Definition MRObjectMeshData.h:14
Definition MRObject.h:274