50 #include "MeshObjectSelectionPlugin.hh" 60 if(_vertexList.empty() )
return;
64 emit log(
LOGERR,tr(
"selectVertices: unable to get object"));
73 emit log(
LOGERR,tr(
"selectAllVertices: Unsupported object Type"));
77 QString selection =
"selectVertices(ObjectId(" + QString::number(_objectId) +
"), [ " + QString::number(_vertexList[0]);
79 for (uint i = 1 ; i < _vertexList.size(); ++i) {
80 selection +=
", " + QString::number(_vertexList[i]);
86 emit scriptInfo(selection);
100 if(_vertexList.empty() )
return;
104 emit log(
LOGERR,tr(
"unselectVertices: unable to get object"));
113 emit log(
LOGERR,tr(
"unselectVertices: Unsupported object Type"));
117 QString selection =
"unselectVertices(ObjectId(" + QString::number(_objectId) +
"), [ " + QString::number(_vertexList[0]);
119 for (uint i = 1 ; i < _vertexList.size(); ++i) {
120 selection +=
", " + QString::number(_vertexList[i]);
126 emit scriptInfo(selection);
137 emit log(
LOGERR,tr(
"selectAllVertices: unable to get object"));
146 emit log(
LOGERR,tr(
"selectAllVertices: Unsupported object Type"));
151 emit scriptInfo(
"selectAllVertices(ObjectId(" + QString::number(_objectId) +
"))");
160 emit log(
LOGERR,tr(
"clearVertexSelection: unable to get object"));
169 emit log(
LOGERR,tr(
"clearVertexSelection: Unsupported object Type"));
174 emit scriptInfo(
"clearVertexSelection(ObjectId(" + QString::number(_objectId) +
"))");
183 emit log(
LOGERR,tr(
"invertVertexSelection: unable to get object"));
192 emit log(
LOGERR,tr(
"invertVertexSelection: Unsupported object Type"));
197 emit scriptInfo(
"invertVertexSelection(ObjectId(" + QString::number(_objectId) +
"))");
206 emit log(
LOGERR,tr(
"selectBoundaryVertices: unable to get object"));
215 emit log(
LOGERR,tr(
"selectBoundaryVertices: Unsupported object Type"));
220 emit scriptInfo(
"selectBoundaryVertices(ObjectId(" + QString::number(_objectId) +
"))");
229 emit log(
LOGERR,tr(
"selectClosestBoundaryVertices: unable to get object"));
238 emit log(
LOGERR,tr(
"selectClosestBoundaryVertices: Unsupported object Type"));
243 emit scriptInfo(
"selectClosestBoundaryVertices(ObjectId(" + QString::number(_objectId) +
"), VertexId)");
252 emit log(
LOGERR,tr(
"shrinkVertexSelection: unable to get object"));
261 emit log(
LOGERR,tr(
"shrinkVertexSelection: Unsupported object Type"));
266 emit scriptInfo(
"shrinkVertexSelection(ObjectId(" + QString::number(_objectId) +
"))");
275 emit log(
LOGERR,tr(
"growVertexSelection: unable to get object"));
284 emit log(
LOGERR,tr(
"growVertexSelection: Unsupported object Type"));
289 emit scriptInfo(
"growVertexSelection(ObjectId(" + QString::number(_objectId) +
"))");
298 emit log(
LOGERR,tr(
"getVertexSelection: unable to get object"));
302 emit scriptInfo(
"getVertexSelection(ObjectId(" + QString::number(_objectId) +
"))");
309 emit log(
LOGERR,tr(
"getVertexSelection: Unsupported object Type"));
322 emit log(
LOGERR,tr(
"deleteVertexSelection: unable to get object"));
331 emit log(
LOGERR,tr(
"deleteVertexSelection: Unsupported object Type"));
336 emit scriptInfo(
"deleteVertexSelection(ObjectId(" + QString::number(_objectId) +
"))");
352 emit log(
LOGERR,
"colorizeVertexSelection: unable to get object");
361 emit log(
LOGERR,
"colorizeVertexSelection: Unsupported object Type");
365 emit scriptInfo(
"colorizeVertexSelection(ObjectId(" + QString::number(_objectId) +
"), " 366 + QString::number(r) +
", " + QString::number(g) +
", " + QString::number(b) +
")");
379 emit log(
LOGERR,tr(
"selectHandleVertices: unable to get object"));
383 if (_vertexList.empty() )
393 emit log(
LOGERR,tr(
"selectHandleVertices: Unsupported object Type"));
397 QString selection =
"selectHandleVertices(ObjectId(" + QString::number(_objectId) +
"), [ " + QString::number(_vertexList[0]);
399 for (uint i = 1 ; i < _vertexList.size(); ++i) {
400 selection +=
", " + QString::number(_vertexList[i]);
406 emit scriptInfo(selection);
413 if(_vertexList.empty())
return;
417 emit log(
LOGERR,tr(
"unselectHandleVertices: unable to get object"));
426 emit log(
LOGERR,tr(
"unselectHandleVertices: Unsupported object Type"));
430 QString selection =
"unselectHandleVertices(ObjectId(" + QString::number(_objectId) +
"), [ " + QString::number(_vertexList[0]);
432 for (uint i = 1 ; i < _vertexList.size(); ++i) {
433 selection +=
", " + QString::number(_vertexList[i]);
439 emit scriptInfo(selection);
448 emit log(
LOGERR,tr(
"clearHandleVertices: unable to get object"));
457 emit log(
LOGERR,tr(
"clearHandleVertices: Unsupported object Type"));
462 emit scriptInfo(
"clearHandleVertices(ObjectId(" + QString::number(_objectId) +
"))");
471 emit log(
LOGERR,tr(
"setAllHandleVertices: unable to get object"));
480 emit log(
LOGERR,tr(
"setAllHandleVertices: Unsupported object Type"));
485 emit scriptInfo(
"setAllHandleVertices(ObjectId(" + QString::number(_objectId) +
"))");
494 emit log(
LOGERR,tr(
"getHandleVertices: unable to get object"));
498 emit scriptInfo(
"getHandleVertices(ObjectId(" + QString::number(_objectId) +
"))");
505 emit log(
LOGERR,tr(
"getHandleVertices: Unsupported object Type"));
518 if(_vertexList.empty() )
return;
522 emit log(
LOGERR,tr(
"selectModelingVertices: unable to get object"));
533 emit log(
LOGERR,tr(
"selectModelingVertices: Unsupported object Type"));
537 QString selection =
"selectModelingVertices(ObjectId(" + QString::number(_objectId) +
"), [ " + QString::number(_vertexList[0]);
539 for (uint i = 1 ; i < _vertexList.size(); ++i) {
540 selection +=
", " + QString::number(_vertexList[i]);
546 emit scriptInfo(selection);
553 if(_vertexList.empty() )
return;
557 emit log(
LOGERR,tr(
"unselectModelingVertices: unable to get object"));
566 emit log(
LOGERR,tr(
"unselectModelingVertices: Unsupported object Type"));
570 QString selection =
"unselectModelingVertices(ObjectId(" + QString::number(_objectId) +
"), [ " + QString::number(_vertexList[0]);
572 for (uint i = 1 ; i < _vertexList.size(); ++i) {
573 selection +=
", " + QString::number(_vertexList[i]);
579 emit scriptInfo(selection);
587 emit log(
LOGERR,tr(
"selectVerticesByValue: unable to get object"));
596 emit log(
LOGERR,tr(
"selectVerticesByValue: Unsupported object Type"));
613 emit log(
LOGERR,tr(
"clearModelingVertices: unable to get object"));
622 emit log(
LOGERR,tr(
"clearModelingVertices: Unsupported object Type"));
627 emit scriptInfo(
"clearModelingVertices(ObjectId(" + QString::number(_objectId) +
"))");
636 emit log(
LOGERR,tr(
"setAllModelingVertices: unable to get object"));
645 emit log(
LOGERR,tr(
"setAllModelingVertices: Unsupported object Type"));
650 emit scriptInfo(
"setAllModelingVertices(ObjectId(" + QString::number(_objectId) +
"))");
657 emit log(
LOGERR,tr(
"getModelingVertices: unable to get object"));
661 emit scriptInfo(
"getModelingVertices(ObjectId(" + QString::number(_objectId) +
"))");
668 emit log(
LOGERR,tr(
"getModelingVertices: Unsupported object Type"));
679 QFile file(_filename);
681 if (!file.exists()) {
682 emit log(
LOGERR,tr(
"Unable to find file: ") + _filename);
686 if (file.open(QFile::ReadOnly)) {
688 QTextStream input(&file);
689 QString header = input.readLine();
691 if (!header.contains(
"Selection")) {
692 emit log(
LOGERR,tr(
"Wrong file header!should be Selection but is ") + header);
696 header = input.readLine();
699 uint vertexCount = header.toUInt(&ok);
702 emit log(
LOGERR,tr(
"Unable to parse header. Cant get vertex count from string: ") + header);
709 emit log(
LOGERR,tr(
"loadSelection: unable to get object"));
731 QStringList inputList = input.readLine().split(
" ");
733 if (inputList.size() != 2) {
734 emit log(
LOGERR,tr(
"Unable to parse entry at vertex index ") + QString::number(vertexId));
738 if (inputList[0] ==
"1")
739 modelingVertices.push_back(vertexId);
741 if (inputList[1] ==
"1")
742 handleVertices.push_back(vertexId);
746 }
while (!input.atEnd());
755 emit log(
LOGERR,tr(
"Unable to open selection file!"));
763 QFile file(_filename);
765 if (file.open(QFile::WriteOnly)) {
766 QTextStream input(&file);
771 emit log(
LOGERR,tr(
"saveFlipperModelingSelection: unable to get object"));
779 input <<
"Selection" << endl;
780 input << mesh->n_vertices() << endl;
782 std::vector< int > modelingVertices = MeshSelection::getArea(mesh, AREA);
783 std::vector< int > handleVertices = MeshSelection::getArea(mesh, HANDLEAREA);
785 std::vector< bool > modelingAll(mesh->n_vertices(),
false);
786 std::vector< bool > handleAll(mesh->n_vertices(),
false);
788 for (uint i=0; i < modelingVertices.size(); i++)
789 modelingAll[ modelingVertices[i] ] =
true;
791 for (uint i=0; i < handleVertices.size(); i++)
792 handleAll[ handleVertices[i] ] =
true;
794 for (uint i=0; i < mesh->n_vertices(); i++)
795 input << (
int) modelingAll[i] <<
" " << (int) handleAll[i] << endl;
802 input <<
"Selection" << endl;
803 input << mesh->n_vertices() << endl;
805 std::vector< int > modelingVertices = MeshSelection::getArea(mesh, AREA);
806 std::vector< int > handleVertices = MeshSelection::getArea(mesh, HANDLEAREA);
808 std::vector< bool > modelingAll(mesh->n_vertices(),
false);
809 std::vector< bool > handleAll(mesh->n_vertices(),
false);
811 for (uint i=0; i < modelingVertices.size(); i++)
812 modelingAll[ modelingVertices[i] ] =
true;
814 for (uint i=0; i < handleVertices.size(); i++)
815 handleAll[ handleVertices[i] ] =
true;
817 for (uint i=0; i < mesh->n_vertices(); i++)
818 input << (
int) modelingAll[i] <<
" " << (int) handleAll[i] << endl;
821 emit log(
LOGERR, tr(
"saveFlipperModelingSelection: Unsupported Type."));
824 emit log(
LOGERR,tr(
"Unable to open selection file!"));
void unselectModelingVertices(int objectId, IdList _vertexList)
Remove vertices from modeling area.
void selectHandleVertices(int objectId, IdList _vertexList)
Set vertices to be part of the handle area.
#define DATA_TRIANGLE_MESH
void shrinkVertexSelection(int _objectId)
Shrink the current vertex selection.
void selectVerticesByValue(int _objectId, QString _component, bool _greater, double _value)
Select vertices by their value.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void saveFlipperModelingSelection(int _objectId, QString _filename)
Save a selection in Flipper Selection Format.
void unselectHandleVertices(int objectId, IdList _vertexList)
Remove vertices from handle area.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
const UpdateType UPDATE_SELECTION_VERTICES(UpdateTypeSet(1)<< 5)
Vertex selection has changed.
void setAllHandleVertices(int objectId)
Set all vertices to be part of the handle area.
void selectModelingVertices(int objectId, IdList _vertexList)
Set vertices to be part of the modeling area.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
int createMeshFromVertexSelection(int _objectId)
set dihedral angle threshold for edge selection
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
bool deleteSelection(MeshT *_mesh, PrimitiveType _primitiveType)
Delete all selected elements of a mesh.
Handle for a vertex entity.
bool dataType(DataType _type) const
std::vector< int > IdList
Standard Type for id Lists used for scripting.
SelectionInterface::PrimitiveType vertexType_
Primitive type handles:
void invertVertexSelection(int _objectId)
Invert the current vertex selection.
void unselectVertices(int objectId, IdList _vertexList)
unselect given vertices
void setAllModelingVertices(int objectId)
Set all vertices to be part of the modeling area.
void selectBoundaryVertices(int _objectId)
Select all boundary vertices of the given object.
IdList getHandleVertices(int objectId)
Get a list of all handle vertices.
void deleteVertexSelection(int _objectId)
Delete vertices and faces that are currently selected.
IdList getModelingVertices(int objectId)
Get a list of all modeling vertices.
void selectVertices(int objectId, IdList _vertexList)
select given vertices
Functions for selection on a mesh.
bool selectVertex(int _objectId, int _idx, bool _fly_to_vertex)
select vertex with id _idx and maybe fly to it
void createMeshFromSelection(MeshT &_mesh, MeshT &_newMesh, PrimitiveType _primitiveType)
Create a new mesh from the selection.
void colorizeSelection(MeshT *_mesh, PrimitiveType _primitiveTypes, int _red, int _green, int _blue, int _alpha)
Colorize the selection.
void selectClosestBoundaryVertices(int _objectId, int _vertexId)
Select all vertices of the boundary close to the given vertex.
void clearHandleVertices(int objectId)
Clear handle Area.
bool selectElement(int _objectId, HandleT _handle, bool _fly_to_element)
set dihedral angle threshold for edge selection
IdList getVertexSelection(int _objectId)
Return a list of all selected vertices.
void closestBoundarySelection(MeshT *_mesh, int _vh, PrimitiveType _primitiveTypes, bool _deselection)
Select all entities that are incident to closest boundary.
void clearModelingVertices(int objectId)
Clear Modeling Area.
void selectAllVertices(int _objectId)
Select all Vertices.
void update_regions(MeshT *_mesh)
Update face selection to correspond to the vertex selection.
void clearVertexSelection(int _objectId)
Unselect all vertices.
void growVertexSelection(int _objectId)
Grow the current vertex selection.
void loadFlipperModelingSelection(int _objectId, QString _filename)
Load a selection from an Flipper selection file for the given object.
void colorizeVertexSelection(int _objectId, int _r, int _g, int _b, int a)
Colorize the vertex selection.
const UpdateType UPDATE_COLOR(UpdateTypeSet(1)<< 10)
Colors have changed.