MeshLib C++ Docs
Loading...
Searching...
No Matches
MRChangeSelectionAction.h
Go to the documentation of this file.
1#pragma once
2#include "MRHistoryAction.h"
3#include "MRObjectMesh.h"
4#include "MRObjectPoints.h"
5
6namespace MR
7{
8
11
13class ChangeMeshFaceSelectionAction : public HistoryAction
14{
15public:
16 using Obj = ObjectMesh;
17
19 ChangeMeshFaceSelectionAction( const std::string& name, const std::shared_ptr<ObjectMesh>& objMesh ):
20 name_{name},
21 objMesh_{objMesh}
22 {
23 if ( !objMesh_ )
24 return;
25 selection_ = objMesh_->getSelectedFaces();
26 }
27
29 ChangeMeshFaceSelectionAction( const std::string& name, const std::shared_ptr<ObjectMesh>& objMesh, FaceBitSet&& newSelection ):
30 name_{name},
31 objMesh_{objMesh}
32 {
33 if ( !objMesh_ )
34 return;
35 selection_ = objMesh_->getSelectedFaces();
36 objMesh_->selectFaces( std::move( newSelection ) );
37 }
38
39 virtual std::string name() const override { return name_; }
40
41 virtual void action( Type ) override
42 {
43 if ( !objMesh_ )
44 return;
45 auto tmp = objMesh_->getSelectedFaces();
46 objMesh_->selectFaces( std::move( selection_ ) );
47 selection_ = std::move( tmp );
48 }
49
50 const FaceBitSet & selection() const { return selection_; }
51
53 static void setObjectDirty( const std::shared_ptr<ObjectMesh>& ) {}
54
55 [[nodiscard]] virtual size_t heapBytes() const override
56 {
57 return name_.capacity() + selection_.heapBytes();
58 }
59
60private:
61 std::string name_;
62 std::shared_ptr<ObjectMesh> objMesh_;
63 FaceBitSet selection_;
64};
65
67class ChangeMeshEdgeSelectionAction : public HistoryAction
68{
69public:
70 using Obj = ObjectMesh;
71
73 ChangeMeshEdgeSelectionAction( const std::string& name, const std::shared_ptr<ObjectMesh>& objMesh ) :
74 name_{ name },
75 objMesh_{ objMesh }
76 {
77 if( !objMesh_ )
78 return;
79 selection_ = objMesh_->getSelectedEdges();
80 }
81
83 ChangeMeshEdgeSelectionAction( const std::string& name, const std::shared_ptr<ObjectMesh>& objMesh, UndirectedEdgeBitSet&& newSelection ) :
84 name_{ name },
85 objMesh_{ objMesh }
86 {
87 if( !objMesh_ )
88 return;
89 selection_ = objMesh_->getSelectedEdges();
90 objMesh_->selectEdges( std::move( newSelection ) );
91 }
92
93 virtual std::string name() const override { return name_; }
94
95 virtual void action( Type ) override
96 {
97 if( !objMesh_ )
98 return;
99 auto tmp = objMesh_->getSelectedEdges();
100 objMesh_->selectEdges( std::move( selection_ ) );
101 selection_ = std::move( tmp );
102 }
103
104 const UndirectedEdgeBitSet & selection() const { return selection_; }
105
107 static void setObjectDirty( const std::shared_ptr<ObjectMesh>& ) {}
108
109 [[nodiscard]] virtual size_t heapBytes() const override
110 {
111 return name_.capacity() + selection_.heapBytes();
112 }
113
114private:
115 std::string name_;
116 std::shared_ptr<ObjectMesh> objMesh_;
117 UndirectedEdgeBitSet selection_;
118};
119
121class ChangeMeshCreasesAction : public HistoryAction
122{
123public:
124 using Obj = ObjectMesh;
125
127 ChangeMeshCreasesAction( const std::string& name, const std::shared_ptr<ObjectMesh>& objMesh ) :
128 name_{ name },
129 objMesh_{ objMesh }
130 {
131 if( !objMesh_ )
132 return;
133 creases_ = objMesh_->creases();
134 }
135
137 ChangeMeshCreasesAction( const std::string& name, const std::shared_ptr<ObjectMesh>& objMesh, UndirectedEdgeBitSet&& newCreases ) :
138 name_{ name },
139 objMesh_{ objMesh }
140 {
141 if( !objMesh_ )
142 return;
143 creases_ = objMesh_->creases();
144 objMesh_->setCreases( std::move( newCreases ) );
145 }
146
147 virtual std::string name() const override { return name_; }
148
149 virtual void action( Type ) override
150 {
151 if( !objMesh_ )
152 return;
153 auto tmp = objMesh_->creases();
154 objMesh_->setCreases( std::move( creases_ ) );
155 creases_ = std::move( tmp );
156 }
157
158 const UndirectedEdgeBitSet & creases() const { return creases_; }
159
161 static void setObjectDirty( const std::shared_ptr<ObjectMesh>& ) {}
162
163 [[nodiscard]] virtual size_t heapBytes() const override
164 {
165 return name_.capacity() + creases_.heapBytes();
166 }
167
168private:
169 std::string name_;
170 std::shared_ptr<ObjectMesh> objMesh_;
171 UndirectedEdgeBitSet creases_;
172};
173
175class ChangePointPointSelectionAction : public HistoryAction
176{
177public:
178 using Obj = ObjectPoints;
179
181 ChangePointPointSelectionAction( const std::string& name, const std::shared_ptr<ObjectPoints>& objPoints ) :
182 name_{ name },
183 objPoints_{ objPoints }
184 {
185 if ( !objPoints_ )
186 return;
187 selection_ = objPoints_->getSelectedPoints();
188 }
189
190 virtual std::string name() const override { return name_; }
191
192 virtual void action( Type ) override
193 {
194 if ( !objPoints_ )
195 return;
196 auto tmp = objPoints_->getSelectedPoints();
197 objPoints_->selectPoints( std::move( selection_ ) );
198 selection_ = std::move( tmp );
199 }
200
201 const VertBitSet& selection() const { return selection_; }
202
204 static void setObjectDirty( const std::shared_ptr<ObjectPoints>& )
205 {}
206
207 [[nodiscard]] virtual size_t heapBytes() const override
208 {
209 return name_.capacity() + selection_.heapBytes();
210 }
211
212private:
213 std::string name_;
214 std::shared_ptr<ObjectPoints> objPoints_;
215 VertBitSet selection_;
216};
217
219
220}
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangeMeshCreasesAction(MR._ByValue_ChangeMeshCreasesAction _other)
unsafe ChangeMeshEdgeSelectionAction(MR._ByValue_ChangeMeshEdgeSelectionAction _other)
unsafe void action(MR.HistoryAction.Type _1)
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangeMeshFaceSelectionAction(MR._ByValue_ChangeMeshFaceSelectionAction _other)
unsafe void action(MR.HistoryAction.Type _1)
unsafe ChangePointPointSelectionAction(MR._ByValue_ChangePointPointSelectionAction _other)
std::string name(const T &primitive)
Definition MRFeatures.h:309
Definition MRCameraOrientationPlugin.h:8