42 #include "ComponentsPlugin.hh" 44 #include <MeshTools/MeshInfoT.hh> 53 emit setSlotDescription(
"splitComponents(int)",
"Split the mesh into connected components. The original mesh is deleted.",
54 QStringList(
"objectId"), QStringList(
"Id of an object"));
56 emit setSlotDescription(
"biggestComponent(int)",
"Get the biggest component and delete the smaller ones.",
57 QStringList(
"objectId"),QStringList(
"Id of an object"));
70 emit log(
LOGERR,
"Unable to get object");
74 QFileInfo fi(obj->
name());
80 emit log(
LOGERR,
"Unable to get mesh");
84 int components = MeshInfo::componentCount( mesh );
89 newIDs.push_back( _objectId );
95 QString currentName = obj->
name();
96 QString extension = currentName.section(
'.', -1);
97 currentName = currentName.section(
'.',0,-2);
100 obj->
setName(currentName+
"_component_"+QString::number(0)+
"."+extension);
103 for(
int i=0; i < components-1; i++){
107 emit copyObject(obj->
id(), id);
110 emit log(
LOGERR,
"Unable to generate a copy of object " + QString::number(obj->
id()) );
117 curObj->
setName(currentName+
"_component_"+QString::number(i+1)+
"."+extension);
121 if ( curMesh == 0 ) {
122 emit log(
LOGERR,
"Unable to get mesh");
129 newIDs.push_back(
id);
134 for (uint i=0; i < newIDs.size(); i++)
144 emit log(
LOGERR,
"Unable to get mesh");
148 int components = MeshInfo::componentCount( mesh );
151 std::vector< int > newIDs;
153 if (components == 1){
154 newIDs.push_back( _objectId );
158 QString currentName = obj->
name();
159 QString extension = currentName.section(
'.', -1);
160 currentName = currentName.section(
'.',0,-2);
163 obj->
setName(currentName+
"_component_"+QString::number(0)+
"."+extension);
165 for(
int i=0; i < components-1; i++){
169 emit copyObject(obj->
id(), id);
172 emit log(
LOGERR,
"Unable to generate a copy of object " + QString::number(obj->
id()) );
179 curObj->
setName(currentName+
"_component_"+QString::number(i+1)+
"."+extension);
183 if ( curMesh == 0 ) {
184 emit log(
LOGERR,
"Unable to get mesh");
191 newIDs.push_back(
id);
196 for (uint i=0; i < newIDs.size(); i++)
204 emit log(
LOGERR,
"Splitting into components currently only supported for meshes");
216 emit log(
LOGERR,
"Unable to get object");
void splitComponent(MeshT *_mesh, MeshT *_copy)
Split mesh into components.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void splitComponents(QMouseEvent *_event)
Split Components of picked object.
void biggestComponent(QMouseEvent *_event)
Split into Components Button was hit.
void selectBiggestComponent(MeshT *_mesh)
Select the biggest component of the mesh.
bool dataType(DataType _type) const
void setDescriptions()
set scripting slot descriptions
void deleteUnselectedFaces(MeshT *_mesh)
Deletes all faces of a mesh that are not selected.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
#define DATA_TRIANGLE_MESH