50 #include "HoleFillerPlugin.hh" 54 #if QT_VERSION >= 0x050000 59 #include "HoleInfoT.hh" 61 #define HOLEINFO "HoleInfoData" 84 QIcon* toolIcon =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"holefilling.png");
86 emit addToolbox( tr(
"Hole Filler") ,
tool_ , toolIcon);
92 emit addPickMode(
"Separator");
93 emit addPickMode(
"Hole Filler");
95 emit setSlotDescription(
"fillAllHoles(int)", tr(
"Fill all holes from a given Mesh"),
96 QString(
"objectId").split(
","), QString(
"Id of the mesh").split(
","));
98 emit setSlotDescription(
"fillHole(int,int)", tr(
"Fill a holes from a given Mesh where edgeHandle is on the boundary"),
99 QString(
"objectId,edgeHandle").split(
","), QString(
"Id of the mesh,Handle of one boundary edge of the hole").split(
","));
107 QModelIndexList indices =
tool_->tableWidget->selectionModel()->selectedRows();
110 for (
int i=0; i < indices.size(); i++){
114 _holeIds.push_back ( holeID );
115 _objIds.push_back( objID );
123 std::vector< int > holes;
124 std::vector< int > objects;
128 QProgressDialog progress(tr(
"Filling holes..."), tr(
"Abort"), 0, holes.size(), 0);
129 progress.setWindowModality(Qt::ApplicationModal);
130 progress.setValue(0);
147 o_it->setObjectData(HOLEINFO, holeInfo);
151 for (uint i = 0; i < objects.size(); i++)
152 if ( objects[i] == o_it->id() ){
155 if (progress.wasCanceled())
158 progress.setValue(++counter);
171 emit log(
LOGWARN, tr(
"HoleFilling unsupported for poly meshes") );
176 if (progress.wasCanceled())
188 std::vector< int > holes;
189 std::vector< int > objects;
206 o_it->setObjectData(HOLEINFO, holeInfo);
210 MeshSelection::clearEdgeSelection(mesh);
213 for (uint i = 0; i < objects.size(); i++)
214 if ( objects[i] == o_it->id() )
218 if ( (objects.size() == 1) && (holes.size() == 1) && ( objects[0] == o_it->id() ) ){
228 object->boundingBox(_bbMin, _bbMax);
247 o_it->setObjectData(HOLEINFO, holeInfo);
251 MeshSelection::clearEdgeSelection(mesh);
254 for (uint i = 0; i < objects.size(); i++)
255 if ( objects[i] == o_it->id() )
259 if ( (objects.size() == 1) && (holes.size() == 1) && ( objects[0] == o_it->id() ) ){
269 object->boundingBox(_bbMin, _bbMax);
287 emit log(
LOGWARN, tr(
"Error for holeMapping_ vector size") );
296 emit log(
LOGWARN, tr(
"Unable to find object for hole (should not happen!!)") );
310 object->setObjectData(HOLEINFO, holeInfo);
327 emit log(
LOGWARN,tr(
"HoleFilling unsupported for poly meshes"));
343 if ( holeInfo == 0 ){
346 o_it->setObjectData(HOLEINFO, holeInfo);
360 o_it->setObjectData(HOLEINFO, holeInfo);
379 bool updated =
false;
416 tool_->tableWidget->clear();
418 tool_->tableWidget->setRowCount ( 0 );
419 tool_->tableWidget->setColumnCount ( 4 );
421 QStringList headerdata;
422 headerdata <<
"Object" <<
"Edges" <<
"Boundary Length" <<
"BB Diagonal";
424 tool_->tableWidget->setHorizontalHeaderLabels(headerdata);
425 tool_->updateGeometry();
440 elements += holeInfo->
holes()->size();
441 tool_->tableWidget->setRowCount ( elements );
444 for (uint i = 0 ; i < holeInfo->
holes()->size() ; ++i ) {
446 QTableWidgetItem*
name =
new QTableWidgetItem( o_it->name() );
448 name->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
449 tool_->tableWidget->setItem(count,0,name);
451 size_t egde_count = 0;
452 double boundaryLength = 0.0;
455 holeInfo->
getHoleInfo(i, egde_count, boundaryLength, bbDiagonal);
458 QTableWidgetItem* size =
new QTableWidgetItem( QString::number( egde_count ) );
460 size->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
461 tool_->tableWidget->setItem(count,1,size);
464 QTableWidgetItem* boundaryLengthWidget =
new QTableWidgetItem( QString::number(boundaryLength) );
465 boundaryLengthWidget->setFlags( 0 );
466 boundaryLengthWidget->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
467 tool_->tableWidget->setItem(count,2,boundaryLengthWidget);
469 QTableWidgetItem* bbDiagonalWidget =
new QTableWidgetItem( QString::number(bbDiagonal) );
470 bbDiagonalWidget->setFlags( 0 );
471 bbDiagonalWidget->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
472 tool_->tableWidget->setItem(count,3,bbDiagonalWidget);
475 holeMapping_.push_back( std::pair<int , int>( o_it->id() , i ) );
488 elements += holeInfo->
holes()->size();
489 tool_->tableWidget->setRowCount ( elements );
492 for (uint i = 0 ; i < holeInfo->
holes()->size() ; ++i ) {
494 QTableWidgetItem*
name =
new QTableWidgetItem( o_it->name() );
496 name->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
497 tool_->tableWidget->setItem(count,0,name);
499 size_t egde_count = 0;
500 double boundaryLength = 0.0;
503 holeInfo->
getHoleInfo(i, egde_count, boundaryLength, bbDiagonal);
506 QTableWidgetItem* size =
new QTableWidgetItem( QString::number( egde_count ) );
508 size->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
509 tool_->tableWidget->setItem(count,1,size);
512 QTableWidgetItem* radius =
new QTableWidgetItem( QString::number(boundaryLength) );
513 radius->setFlags( 0 );
514 radius->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
515 tool_->tableWidget->setItem(count,2,radius);
518 QTableWidgetItem* bbDiagonalWidget =
new QTableWidgetItem( QString::number(bbDiagonal) );
519 bbDiagonalWidget->setFlags( 0 );
520 bbDiagonalWidget->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
521 tool_->tableWidget->setItem(count,3,bbDiagonalWidget);
524 holeMapping_.push_back( std::pair<int , int>( o_it->id() , i ) );
532 tool_->tableWidget->resizeColumnToContents ( 1 );
541 emit log(
LOGERR, tr(
"Could not get object from ID.") );
545 emit scriptInfo(
"fillAllHoles( ObjectId )" );
558 object->setObjectData(HOLEINFO, holeInfo);
575 emit log(
LOGERR, tr(
"HoleFilling unsopported for poly meshes.") );
587 emit log(
LOGERR, tr(
"Could not get object from ID.") );
591 emit scriptInfo(
"fillHole( ObjectId , EdgeHandle )" );
604 object->setObjectData(HOLEINFO, holeInfo);
608 TriMesh::EdgeHandle eh(_edgeHandle);
610 if ( !eh.is_valid() || !mesh->is_boundary(eh) ){
611 emit log(
LOGERR, tr(
"Invalid edge handle.") );
629 emit log(
LOGERR, tr(
"HoleFilling unsopported for poly meshes.") );
634 #if QT_VERSION < 0x050000 std::vector< std::pair< int, int > > holeMapping_
map from the index in the table to (object-id, hole-id)
void slotItemSelectionChanged()
slot for displaying selected holes
void fillHole(int _objectID, int _edgeHandle)
fill a hole in given object where _edgeHandle is on the boundary
Type for a MeshObject containing a triangle mesh.
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
void fillAllHoles(int _stages=3)
fill all holes
void pluginsInitialized()
add PickModes after initialization
bool getObject(int _identifier, BSplineCurveObject *&_object)
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
bool dataType(DataType _type) const
void detectButton()
detect holes on all objects
void slotFillSelection()
Fill all selected holes.
void getHoleInfo(const unsigned int _index, size_t &_edges, typename MeshT::Scalar &_diagonal, typename MeshT::Scalar &_boundaryLength) const
void slotCellDoubleClicked(int _row, int _col)
Slot for filling holes from double-clicked rows.
const QStringList ALL_OBJECTS
Iterable object range.
Kernel::Normal Normal
Normal type.
PolyMeshObject * polyMeshObject(BaseObjectData *_object)
Cast an BaseObject to a PolyMeshObject if possible.
void flyTo(const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time)
Fly to point and viewing direction (animated).
QString name()
Return a name for the plugin.
Functions for selection on a mesh.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
HoleFillerToolbarWidget * tool_
Widget for Toolbox.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
TriMeshObject * triMeshObject(BaseObjectData *_object)
Cast an BaseObject to a TriMeshObject if possible.
void slotObjectUpdated(int _identifier, const UpdateType &_type)
check for holes if an object has changed
void initializePlugin()
Initialize the toolbox widget.
void getHolePostitionInfo(const int _index, typename MeshT::Normal &_holeNormal, typename MeshT::Point &_holeCenter) const
Collect information to fly to a hole.
void fillHole(int _index, int _stages=3)
fill hole with given index
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
void fillAllHoles(int _objectID)
fill all holes from a given object
void getSelectedHoles(std::vector< int > &_holeIds, std::vector< int > &_objIds)
get a map from objectID to (selected) holeIDs
Type for a Meshobject containing a poly mesh.
void getHoles()
get all holes and store them internally
Kernel::Point Point
Coordinate type.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
std::vector< std::vector< typename MeshT::EdgeHandle > > * holes()
get the holes vector
HoleFillerPlugin()
Constructor.
void selectHole(int _index)
select a hole with given index
void update_menu()
update the entries in the tableWidget
Kernel::Scalar Scalar
Scalar type.
#define DATA_TRIANGLE_MESH
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.