For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Write/Read a Xml file

Jane Hu's picture
Forums: 

Hello,

I am trying to use LCAF library to write out a Xml file which would contain what BRepTools::Write() provides, as well as some TDataStd_Name,TDataStd_ExtStringArray,TDataStd_RealArray and TDataStd_IntegerArray attributes under each TShape. For this, I have created a label tree, with each TDataStd_Shape attribute attached to each first level of labels(under mainLabel), then second level are those TDataStd_Name, TDataStd_ExtStringArray, TDataStd_RealArray and TDataStd_IntegerArray attributes corresponding to the upper level TShape.

I don't know what the procedure of writing the document is(Which files to look into), and which calls I should use to add those into document. Any help would be greatly appreciated!

Jane

Patrik Mueller's picture

Hi,

I haven't used LCAF - but I think the release notes for version 5.2.2 has some infos.

Here is some code from me for working with XDE - it should be similar!

Hope it helps,

Patrik

bool Im_PluginIOXDE::InitXDE(XDEVersion theVersion)
{
bool result = false;
Handle_XCAFApp_Application m_pXDE;

m_pXDE = XCAFApp_Application::GetApplication();
if (!m_pXDE.IsNull())
{
// m_pXDE->NewDocument(TCollection_ExtendedString ("MDTV-XCAF"), (Handle_TDocStd_Document)m_pOCAFDoc);

switch (theVersion)
{
case XCAF_XML:
m_pXDE->NewDocument(TCollection_ExtendedString ("XmlXCAF"), m_pXDEDoc);
break;
case XCAF_BINARY:
m_pXDE->NewDocument(TCollection_ExtendedString ("BinXCAF"), m_pXDEDoc);
break;
case OCAF_XML:
m_pXDE->NewDocument(TCollection_ExtendedString ("XmlOcaf"), m_pXDEDoc);
break;
case OCAF_DEFAULT:
m_pXDE->NewDocument(TCollection_ExtendedString ("MDTV-Standard"), m_pXDEDoc);
break;
case OCAF_BINARY:
m_pXDE->NewDocument(TCollection_ExtendedString ("BinOcaf"), m_pXDEDoc);
break;
default:
m_pXDE->NewDocument(TCollection_ExtendedString ("MDTV-XCAF"), m_pXDEDoc);
break;
};

if (!m_pXDEDoc.IsNull())
{
m_pXDEShapes = XCAFDoc_DocumentTool::ShapeTool (m_pXDEDoc->Main());
m_pXDEColors = XCAFDoc_DocumentTool::ColorTool(m_pXDEDoc->Main());
m_pXDELayers = XCAFDoc_DocumentTool::LayerTool(m_pXDEDoc->Main());
result = true;
}
}
return result;
}

bool Im_PluginIOXDE::ReadSceneLabel(TDF_Label SceneLabel, Standard_CString FileName)
{
TCollection_ExtendedString tmpFileName(FileName);
Handle_XCAFApp_Application m_pXDE;
m_pXDE = XCAFApp_Application::GetApplication();
if (!m_pXDE.IsNull())
{
CDF_RetrievableStatus tmpResult = m_pXDE->Open(tmpFileName, m_pXDEDoc);

if ((!m_pXDEDoc.IsNull()) && (tmpResult == CDF_RS_OK))
{
m_pXDEShapes = XCAFDoc_DocumentTool::ShapeTool (m_pXDEDoc->Main());
m_pXDEColors = XCAFDoc_DocumentTool::ColorTool(m_pXDEDoc->Main());
m_pXDELayers = XCAFDoc_DocumentTool::LayerTool(m_pXDEDoc->Main());
return true;
}
return false;
}
return false;
}

bool Im_PluginIOXDE::WriteSceneLabel(TDF_Label SceneLabel, Standard_CString FileName)
{
TCollection_ExtendedString tmpFileName(FileName);
Handle_XCAFApp_Application m_pXDE;
m_pXDE = XCAFApp_Application::GetApplication();
if (!m_pXDE.IsNull())
{
m_pXDE->SaveAs(m_pXDEDoc, tmpFileName);
return true;
}
return false;
}

Jane Hu's picture

Thank you, Patrik. I am now looking at the code, I am not very familiar with LCAF or OCAF, so hopefully I can figure out some way to implement it through your code.

Thanks!

Jane