Example #1
0
TopoDS_Shape IO::loadPartFile(const QString& filename, Handle_Message_ProgressIndicator indicator)
{
  switch (partFormat(filename)) {
  case StepFormat:
    return IO::loadStepFile(filename, indicator);
  case IgesFormat:
    return IO::loadIgesFile(filename, indicator);
  case OccBrepFormat:
    return IO::loadBrepFile(filename, indicator);
  default:
    return TopoDS_Shape();
  }
  return TopoDS_Shape();
}
Example #2
0
void SMESH_MesherHelper::SetSubShape(const int aShID)
{
  if ( aShID == myShapeID )
    return;
  if ( aShID > 1 )
    SetSubShape( GetMeshDS()->IndexToShape( aShID ));
  else
    SetSubShape( TopoDS_Shape() );
}
Example #3
0
TopoDS_Shape Feature::getSolid(const TopoDS_Shape& shape)
{
    if (shape.IsNull())
        Standard_Failure::Raise("Shape is null");
    TopExp_Explorer xp;
    xp.Init(shape,TopAbs_SOLID);
    for (;xp.More(); xp.Next()) {
        return xp.Current();
    }

    return TopoDS_Shape();
}
Example #4
0
//=======================================================================
//function : GetMinDistance
//purpose  : 
//=======================================================================
Standard_Real GEOMUtils::GetMinDistance
                               (const TopoDS_Shape& theShape1,
                                const TopoDS_Shape& theShape2,
                                gp_Pnt& thePnt1, gp_Pnt& thePnt2)
{
  Standard_Real aResult = 1.e9;

  // Issue 0020231: A min distance bug with torus and vertex.
  // Make GetMinDistance() return zero if a sole VERTEX is inside any of SOLIDs

  // which of shapes consists of only one vertex?
  TopExp_Explorer exp1(theShape1,TopAbs_VERTEX), exp2(theShape2,TopAbs_VERTEX);
  TopoDS_Shape V1 = exp1.More() ? exp1.Current() : TopoDS_Shape();
  TopoDS_Shape V2 = exp2.More() ? exp2.Current() : TopoDS_Shape();
  exp1.Next(); exp2.Next();
  if ( exp1.More() ) V1.Nullify();
  if ( exp2.More() ) V2.Nullify();
  // vertex and container of solids
  TopoDS_Shape V = V1.IsNull() ? V2 : V1;
  TopoDS_Shape S = V1.IsNull() ? theShape1 : theShape2;
  if ( !V.IsNull() ) {
    // classify vertex against solids
    gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( V ) );
    for ( exp1.Init( S, TopAbs_SOLID ); exp1.More(); exp1.Next() ) {
      BRepClass3d_SolidClassifier classifier( exp1.Current(), p, 1e-6);
      if ( classifier.State() == TopAbs_IN ) {
        thePnt1 = p;
        thePnt2 = p;
        return 0.0;
      }
    }
  }
  // End Issue 0020231

  // skl 30.06.2008
  // additional workaround for bugs 19899, 19908 and 19910 from Mantis
  double dist = GEOMUtils::GetMinDistanceSingular
      (theShape1, theShape2, thePnt1, thePnt2);

  if (dist > -1.0) {
    return dist;
  }

  BRepExtrema_DistShapeShape dst (theShape1, theShape2);
  if (dst.IsDone()) {
    gp_Pnt P1, P2;

    for (int i = 1; i <= dst.NbSolution(); i++) {
      P1 = dst.PointOnShape1(i);
      P2 = dst.PointOnShape2(i);

      Standard_Real Dist = P1.Distance(P2);
      if (aResult > Dist) {
        aResult = Dist;
        thePnt1 = P1;
        thePnt2 = P2;
      }
    }
  }

  return aResult;
}
Example #5
0
 TopoDS_Shape Page::lookupShape ( QVector<uint>& /*id_path*/ ) const
 {
   return TopoDS_Shape(); // Not needed (currently) in 2D context
 }
Example #6
0
 TopoDS_Shape Page::lookupShape ( QStringList& /*path_components*/ ) const
 {
   return TopoDS_Shape(); // Not needed (currently) in 2D context
 }
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;
}