Esempio n. 1
0
void DigikamImageView::addAssignNameOverlay(ImageDelegate* delegate)
{
#ifdef HAVE_KFACE
    AssignNameOverlay* const nameOverlay = new AssignNameOverlay(this);
    addOverlay(nameOverlay, delegate);

    connect(nameOverlay, SIGNAL(confirmFaces(QList<QModelIndex>,int)),
            this, SLOT(confirmFaces(QList<QModelIndex>,int)));

    connect(nameOverlay, SIGNAL(removeFaces(QList<QModelIndex>)),
            this, SLOT(removeFaces(QList<QModelIndex>)));
#else
    Q_UNUSED(delegate);
#endif /* HAVE_KFACE */
}
Esempio n. 2
0
void AssignNameOverlay::slotRejected(const ImageInfo& info, const QVariant& faceIdentifier)
{
    Q_UNUSED(info);
    Q_UNUSED(faceIdentifier);
    //FaceTagsIface face = FaceTagsIface::fromVariant(faceIdentifier);
    emit removeFaces(affectedIndexes(index()));
    hide();
}
Standard_Boolean ShHealOper_RemoveFace::removeFaces(const TopoDS_Solid& theShape,
                                                    TopoDS_Shape& theNewShape)
{
  Standard_Boolean isDone = Standard_False;
  TopoDS_Solid aSol;
  BRep_Builder aB;
  aB.MakeSolid(aSol);
  TopoDS_Compound aComp;
  aB.MakeCompound(aComp);
  Standard_Boolean isAddSol = Standard_False, isAddComp = Standard_False;

  //firslty faces will be deleted from each shell.
  TopoDS_Iterator aItSol(theShape,Standard_False);
  for( ; aItSol.More(); aItSol.Next()) {
    TopoDS_Shape aSh = aItSol.Value();
    TopoDS_Shape aNewShape;
    if(removeFaces(aSh,aNewShape)) 
      isDone = Standard_True;
    
    if(aNewShape.IsNull())
      continue;
    else if(aNewShape.ShapeType() == TopAbs_SHELL ) {
      aB.Add(aSol,aNewShape);
      isAddSol = Standard_True;
    }
    else {
      aB.Add(aComp,aNewShape);
      isAddComp = Standard_True;
    }
    
  }
  if(isDone) {
    //for getting correct solids class ShapeFix_Solid will be used.
    if(isAddSol) {
      Handle(ShapeFix_Solid) aSfSol = new ShapeFix_Solid(aSol);
      aSfSol->FixShellMode()= Standard_False;
      aSfSol->Perform();
      TopoDS_Shape aresSol = aSfSol->Shape();
      if(!isAddComp) 
        theNewShape = aresSol;
      else 
        aB.Add(aComp,aresSol);
    }
    else if(isAddComp)
        theNewShape = aComp;
    else
      theNewShape.Nullify();
  }
  else
    theNewShape = theShape; 
  return isDone;
}
Esempio n. 4
0
void DigikamImageView::addRejectionOverlay(ImageDelegate* delegate)
{
#ifdef HAVE_KFACE
    FaceRejectionOverlay* const rejectionOverlay = new FaceRejectionOverlay(this);

    connect(rejectionOverlay, SIGNAL(rejectFaces(QList<QModelIndex>)),
            this, SLOT(removeFaces(QList<QModelIndex>)));

    addOverlay(rejectionOverlay, delegate);
#else
    Q_UNUSED(delegate);
#endif /* HAVE_KFACE */
}
Standard_Boolean ShHealOper_RemoveFace::Perform(const TopTools_SequenceOfShape& theRemoveFaces)
{
  myDone = Standard_False;
  myErrorStatus = ShHealOper_NotError;
  if(myInitShape.IsNull()) {
    myErrorStatus = ShHealOper_InvalidParameters;
    return myDone;
  }
  if(theRemoveFaces.IsEmpty())
    return Standard_False;
  myMapFaces.Clear();
  
  Standard_Integer i=1; 
  for( ; i <= theRemoveFaces.Length(); i++)
    myMapFaces.Add(theRemoveFaces.Value(i));
  
  myDone = removeFaces(myInitShape,myResultShape);
  return myDone;
}
Standard_Boolean ShHealOper_RemoveFace::removeFaces(const TopoDS_Shape& theShape,
                                                    TopoDS_Shape& theNewShape)
{
  Standard_Boolean isDone = Standard_False;
  
  TopAbs_ShapeEnum aType = theShape.ShapeType();
  theNewShape = theShape;
  if(!myMapFaces.Extent())
    return isDone;
  if( aType == TopAbs_WIRE || aType == TopAbs_EDGE || aType == TopAbs_VERTEX)
      return isDone;
  if(aType == TopAbs_FACE && myMapFaces.Contains(theShape)) {
    removePCurve(TopoDS::Face(theShape));
    
    myContext->Remove(theShape);
    myMapFaces.Remove(theShape);
    //theNewShape = TopoDS_Shape();
    theNewShape.Nullify();
    isDone = Standard_True;
  }
  else if(aType == TopAbs_SHELL) {
    isDone = removeFaces(TopoDS::Shell(theShape),theNewShape);
    return isDone;
  }
  else if(aType == TopAbs_SOLID) {
    isDone = removeFaces(TopoDS::Solid(theShape),theNewShape);
    myContext->Replace(theShape,theNewShape);
  }
  else if(aType == TopAbs_COMPSOLID) {

    //in the case of compsolid method for removing faces for solid
    //will be used.

    TopExp_Explorer aExpShell(theShape,TopAbs_SHELL);
    TopoDS_Solid aSol;
    BRep_Builder aB;
    aB.MakeSolid(aSol);
    for( ; aExpShell.More(); aExpShell.Next()) {
      aB.Add(aSol,aExpShell.Current());
    }
    TopoDS_Shape aNewShape;
    isDone =  removeFaces(aSol,aNewShape);
    if(isDone)
       myContext->Replace(theShape,theNewShape);
    
  }
  else if(aType == TopAbs_COMPOUND) {
    //in the case of compounf faces will be removed from each part of compound separately

    TopoDS_Compound aComp;
    TopoDS_Iterator aItShape(theShape,Standard_False);
    BRep_Builder aB;
    aB.MakeCompound(aComp);
    Standard_Integer nbs =0;
    for( ; aItShape.More() ; aItShape.Next()) {

      TopoDS_Shape aNShape;
      if( removeFaces(aItShape.Value(),aNShape)) {
        isDone = Standard_True;
        myContext->Replace(aItShape.Value(),aNShape);
      }
      if(!aNShape.IsNull()) {
        aB.Add(aComp,aNShape);
        nbs++;
      }
    }
    if(isDone) {
      if(nbs) 
        theNewShape = aComp;
      else
        theNewShape =TopoDS_Shape();
      myContext->Replace(theShape,theNewShape);
    }
   
  }
  return isDone;
}