View Issue Details

IDProjectCategoryView StatusLast Update
0029373CommunityOCCT:Data Exchangepublic2022-10-24 10:39
ReporterBenjaminBihler Assigned Togka  
PrioritynormalSeverityminor 
Status newResolutionopen 
Target Version7.8.0 
Summary0029373: STEP exporter writes TopoDS_Wire as TopoDS_Edges
DescriptionThe problem has been described here: https://www.opencascade.com/content/save-wire-step-file.

If a TopoDS_Wire is exported to a STEP file and read back, then it appears as a compound of TopoDS_Edges. If this STEP file is opened in CATIA, the connectivity is lost. On the other hand, if CATIA exports a wire to a STEP file, both CATIA and OCCT get a wire when they read in the file. This greatly reduces the convenience of OCCT STEP files when working with CATIA.

An example program is pasted as "Steps To Reproduce".

Ideas from the reporter (who is not at all familiar with the STEP format):
CATIA seems to export a wire as a "COMPOSITE_CURVE", while OCCT exports the wire as a "GEOMETRIC_CURVE_SET". The former seems to be somehow better...?
Steps To Reproducemain.cpp, please also see the attached files:

#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <STEPControl_Reader.hxx>
#include <STEPControl_Writer.hxx>
#include <GC_MakeSegment.hxx>

#include <iostream>

void checkStepFile(const std::string& filePath)
{
    STEPControl_Reader reader;

    IFSelect_ReturnStatus status = reader.ReadFile(filePath.c_str());

    if (status != IFSelect_RetDone)
    {
        std::cerr << "Could not read file." << std::endl;
        exit(1);
    }

    bool failsonly = false;
    reader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity);

    int rootsNumber = reader.NbRootsForTransfer();
    reader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity);

    for (Standard_Integer rootIndex = 1; rootIndex <= rootsNumber; rootIndex++)
    {
        reader.TransferRoot(rootIndex);
        int shapesNumber = reader.NbShapes();

        for (int shapeIndex = 1; shapeIndex <= shapesNumber; shapeIndex++)
        {
            TopoDS_Shape shape = reader.Shape(shapeIndex);

            std::cout << "Shape " << shapeIndex << " has type: " << shape.ShapeType()
                    << std::endl;

            if (TopAbs_COMPOUND == shape.ShapeType())
            {
                std::cout << "Exploring shape." << std::endl;

                for (TopExp_Explorer explorer(shape, TopAbs_EDGE, TopAbs_WIRE); explorer.More();
                        explorer.Next())
                {
                    std::cout << "Compound contains an edge." << std::endl;
                }

                for (TopExp_Explorer explorer(shape, TopAbs_WIRE); explorer.More();
                        explorer.Next())
                {
                    std::cout << "Compound contains a wire." << std::endl;
                }
            }
        }
    }
}

int main(int, char**)
{
    const std::string filePath = "C://Test.stp";
    const std::string catiaFilePath = "C://TestCATIA.stp";

    TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(
            GC_MakeSegment(gp_Pnt(0., 0., 0.), gp_Pnt(0., 10., 0.)).Value());
    TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(
            GC_MakeSegment(gp_Pnt(0., 10., 0.), gp_Pnt(10., 10., 0.)).Value());
    TopoDS_Edge aEdge3 = BRepBuilderAPI_MakeEdge(
            GC_MakeSegment(gp_Pnt(10., 10., 0.), gp_Pnt(10., 0., 0.)).Value());
    TopoDS_Edge aEdge4 = BRepBuilderAPI_MakeEdge(
            GC_MakeSegment(gp_Pnt(10., 0., 0.), gp_Pnt(0., 0., 0.)).Value());

    TopoDS_Wire aWire1 =
            BRepBuilderAPI_MakeWire(aEdge1, aEdge2, aEdge3, aEdge4).Wire();

    STEPControl_Writer writer;
    writer.Transfer(aWire1, STEPControl_AsIs);
    writer.Write(filePath.c_str());

    std::cout << std::endl << "Checking the file that we have written:"
            << std::endl << std::endl;

    checkStepFile(filePath);

    std::cout << std::endl << "Checking the file that CATIA has written:"
            << std::endl << std::endl;

    checkStepFile(catiaFilePath);

    return 0;
}
TagsNo tags attached.
Test case number

Attached Files

  • TestCATIA.stp (4,662 bytes)
  • TestOCCT.stp (3,243 bytes)

Relationships

related to 0025690 newgka STEPCAFControl_Writer should export Wire to COMPOSITE_CURVE rather than GEOMETRIC_CURVE_SET. 

Activities

BenjaminBihler

2017-12-06 15:51

developer  

TestCATIA.stp (4,662 bytes)

BenjaminBihler

2017-12-06 15:52

developer  

TestOCCT.stp (3,243 bytes)

Issue History

Date Modified Username Field Change
2017-12-06 15:51 BenjaminBihler New Issue
2017-12-06 15:51 BenjaminBihler Assigned To => gka
2017-12-06 15:51 BenjaminBihler File Added: TestCATIA.stp
2017-12-06 15:52 BenjaminBihler File Added: TestOCCT.stp
2018-02-09 11:21 BenjaminBihler Relationship added related to 0025690
2019-07-10 21:51 abv Target Version 7.4.0 => 7.5.0
2020-09-17 20:04 gka Target Version 7.5.0 => 7.6.0
2021-10-18 14:02 kgv Target Version 7.6.0 => 7.7.0
2022-10-24 10:39 szy Target Version 7.7.0 => 7.8.0