Пример #1
0
TopoDS_Shape loadShapeFromFile(
        const char* fileName,
        Handle_Message_ProgressIndicator indicator)
{
    TopoDS_Shape result;

    if (!indicator.IsNull())
        indicator->NewScope(30, "Loading file");
    READER reader;
    const int status = reader.ReadFile(const_cast<Standard_CString>(fileName));
    if (!indicator.IsNull())
        indicator->EndScope();
    if (status == IFSelect_RetDone) {
        if (!indicator.IsNull()) {
            reader.WS()->MapReader()->SetProgress(indicator);
            indicator->NewScope(70, "Translating file");
        }
        reader.NbRootsForTransfer();
        reader.TransferRoots();
        result = reader.OneShape();
        if (!indicator.IsNull()) {
            indicator->EndScope();
            reader.WS()->MapReader()->SetProgress(NULL);
        }
    }
    return result;
}
Пример #2
0
/*! \brief Write a topologic shape to a file (STEP format)
 *  \param shape Topologic shape to write
 *  \param fileName Path to the file to write
 *  \param indicator Indicator to notify the writing progress
 */
void IO::writeStepFile(const TopoDS_Shape& shape,
                       const QString& fileName,
                       Handle_Message_ProgressIndicator indicator)
{
  IFSelect_ReturnStatus status;
  STEPControl_Writer writer;
  if (!indicator.IsNull())
    writer.WS()->MapReader()->SetProgress(indicator);
  status = writer.Transfer(shape, STEPControl_AsIs);
  status = writer.Write(fileName.toAscii().data());
  writer.WS()->MapReader()->SetProgress(NULL);
}
Пример #3
0
/*! \brief Write a topologic shape to a file (IGES format)
 *  \param shape Topologic shape to write
 *  \param fileName Path to the file to write
 *  \param indicator Indicator to notify the writing progress
 */
void IO::writeIgesFile(const TopoDS_Shape& shape,
                       const QString& fileName,
                       Handle_Message_ProgressIndicator indicator)
{
  IGESControl_Controller::Init();
  IGESControl_Writer writer(Interface_Static::CVal("XSTEP.iges.unit"),
                            Interface_Static::IVal("XSTEP.iges.writebrep.mode"));
  if (!indicator.IsNull())
    writer.TransferProcess()->SetProgress(indicator);
  writer.AddShape(shape);
  writer.ComputeModel();
  writer.Write(fileName.toAscii().data());
  writer.TransferProcess()->SetProgress(NULL);
}