View Issue Details

IDProjectCategoryView StatusLast Update
0032499CommunityPRODUCTS:DXF Importpublic2021-08-05 12:56
Reporterlucas_morona_164500 Assigned Togka 
PrioritynormalSeveritymajor 
Status newResolutionopen 
PlatformWindows OSWindows 10 
Product Version7.3.0 
Summary0032499: DXF Import - Is not possible import MESH object from DXF file
DescriptionTry to import any file with MESH object from DXF file,OCC does not import MESH object.
Steps To ReproduceFollow the code to import objects from DXF.

// To extract name of layers is necessary to have a TDocStd_Document
    Handle(TDocStd_Document) document;
    Handle(XCAFApp_Application) application = XCAFApp_Application::GetApplication();

    // Is necessary create a new document
    application->NewDocument(m_filePath.toLatin1().constData(), document);
    DXFCAFControl_Reader dxfReaderLayer;
    dxfReaderLayer.SetNameMode(true);
    TCollection_AsciiString filePathUtf8(m_filePath.toUtf8().constData());
    dxfReaderLayer.ReadFile(filePathUtf8.ToCString());

    // You must transfer your reader to document
    dxfReaderLayer.Transfer(document);
    TDF_Label rootLabel = document->Main();

    // This object is important to extract layer from DXF
    Handle(XCAFDoc_LayerTool) layerTool = XCAFDoc_DocumentTool::LayerTool(rootLabel);

    // This object is important to extract shapes from layers
    Handle(XCAFDoc_ShapeTool) shapeTool = XCAFDoc_DocumentTool::ShapeTool(rootLabel);

    TDF_ChildIterator it;
    Handle(TDataStd_Name) layerName;
    for (it.Initialize(rootLabel, Standard_True); it.More(); it.Next())
    {
        // Get only the layers attributes
        TDF_Label labelLayer = it.Value();
        layerTool->FindAttribute(TDataStd_Name::GetID(), layerName);
        if (layerTool->IsLayer(labelLayer))
        {
            if (labelLayer.FindAttribute(TDataStd_Name::GetID(), layerName))
            {
                TDF_LabelSequence labelSequence = TDF_LabelSequence();
                layerTool->GetShapesOfLayer(labelLayer, labelSequence);
                // Is necessary to take the layer of any edge
                int numbersOfShapes = labelSequence.Size();
                if (numbersOfShapes > 0)
                {
                    QString layer = QString(TCollection_AsciiString(layerName->Get()).ToCString());

                    for (TDF_LabelSequence::Iterator labelIt(labelSequence); labelIt.More(); labelIt.Next())
                    {
                        TDF_Label shapeLabel = labelIt.Value();
                        TopoDS_Shape layerShape = shapeTool->GetShape(shapeLabel);

                        if (layerShape.IsNull())
                        {
                            continue;
                        }

                        if (TopAbs_VERTEX == layerShape.ShapeType())
                        {
                            insertLayer(layer);
                            insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), layerShape);
                            m_numberOfVertices++;
                        }
                        else if (TopAbs_EDGE == layerShape.ShapeType())
                        {
                            insertLayer(layer);
                            insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), layerShape);
                            m_numberOfLines++;
                        }
                        else if (TopAbs_WIRE == layerShape.ShapeType())
                        {
                            insertLayer(layer);
                            insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), layerShape);
                            m_numberOfWires++;
                        }
                        else if (TopAbs_FACE == layerShape.ShapeType())
                        {
                            insertLayer(layer);
                            insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), layerShape);
                            m_numberOfFaces++;
                        }
                        else if (TopAbs_COMPOUND == layerShape.ShapeType())
                        {
                            insertLayer(layer);

                            for (TopExp_Explorer explorer(layerShape, TopAbs_ShapeEnum::TopAbs_WIRE); explorer.More(); explorer.Next())
                            {
                                TopoDS_Wire wire = TopoDS::Wire(explorer.Current());

                                if (!wire.IsNull())
                                {
                                    insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), wire);
                                    m_numberOfWires++;
                                }
                            }

                            for (TopExp_Explorer explorer(layerShape, TopAbs_ShapeEnum::TopAbs_FACE); explorer.More(); explorer.Next())
                            {
                                TopoDS_Face face = TopoDS::Face(explorer.Current());

                                if (!face.IsNull())
                                {
                                    insertVisibilityShape(QString(TCollection_AsciiString(layerName->Get()).ToCString()), face);
                                    m_numberOfFaces++;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
TagsNo tags attached.
Test case number

Attached Files

  • MESH.dxf (170,680 bytes)

Activities

kgv

2021-07-30 17:18

developer   ~0102897

Lucas, could you please attach any sample DXF file reproducing the issue?

lucas_morona_164500

2021-08-05 12:55

reporter  

MESH.dxf (170,680 bytes)

lucas_morona_164500

2021-08-05 12:56

reporter   ~0102995

I have pushed a file

Issue History

Date Modified Username Field Change
2021-07-29 17:51 lucas_morona_164500 New Issue
2021-07-29 17:51 lucas_morona_164500 Assigned To => gka
2021-07-30 17:17 kgv Summary Is not possible import MESH object from DXF file. => DXF Import - Is not possible import MESH object from DXF file
2021-07-30 17:17 kgv Steps to Reproduce Updated
2021-07-30 17:18 kgv Note Added: 0102897
2021-08-05 12:55 lucas_morona_164500 File Added: MESH.dxf
2021-08-05 12:56 lucas_morona_164500 Note Added: 0102995