Using Datakit SDK for OpenCascade needs to go through assembly and construction tree like standard integration .
Then for Dtk_Node with type Dtk_Node::BodyType you can access to the Dtk_Body and convert it into TopoDS_Shape object.
The following sample show you how to convert a Dtk_Body to an Opencascade binary object : TopoDS_Shape
#include "../LibReadersSample/WritingSample/PdfWrite/PdfWrite.hpp"
#include "../LibReadersSample/WritingSample/XmlWrite/XmlWrite.hpp"
#include <TopoDS_Shape.hxx>
#include <BRepTools.hxx>
#if defined(DTK_USE_OCCRW_SDK)
#else //defined(DTK_USE_DKOC_SDK)
#endif
#include <Standard_Version.hxx>
{
#if defined(OCC_VERSION_COMPLETE)
std::cout << "OpenCascade version: " << OCC_VERSION_COMPLETE << std::endl;
#elif defined(OCC_VERSION_STRING)
std::cout << "OpenCascade version: " << OCC_VERSION_STRING << std::endl;
#elif defined(OCC_VERSION_MAJOR) && defined(OCC_VERSION_MINOR) && defined(OCC_VERSION_MAINTENANCE)
std::cout << "OpenCascade version: "
<< OCC_VERSION_MAJOR << "."
<< OCC_VERSION_MINOR << "."
<< OCC_VERSION_MAINTENANCE << std::endl;
#else
std::cout << "OpenCascade version macro not available in this OCC headers set." << std::endl;
#endif
}
{
int NodeInfiniteGeometry = inNode->GetInfos()->GetInfiniteGeometryFlag();
if (NodeInfiniteGeometry == 0)
{
{
{
}
static bool occVersionPrinted = false;
if( !occVersionPrinted )
{
occVersionPrinted = true;
}
TopoDS_Shape res;
if (res.IsNull())
{
return;
}
static int numbrep = 0;
numbrep++;
{
bodyinfo = inNode->GetInfos();
if (bodyname.
len() == 0) bodyname =
"???";
}
std::cout <<
"Writing ToOpenCascade Body " << numbrep <<
" name: " << bodyname.
c_str() << std::endl;
filebrep += "_";
filebrep += ".brep";
BRepTools::Write(res, filebrep.
c_str());
TopoDS_Shape facewithid;
TmpBody->GetLump(0,
Lump);
{
{
{
Shell->GetFace(0, Face, orient);
{
SampleBrepFileForFace.
add_int(faceid);
SampleBrepFileForFace += ".brep";
BRepTools::Write(facewithid, SampleBrepFileForFace.
c_str());
}
}
}
}
if( !facewithid.IsNull() )
{
Dtk_ErrorStatus err = TmpBody->GetEntities( DatakitFaceID, CorrespondingFaces );
std::unordered_map<Dtk_ID, std::vector<Dtk_Size_t>> map;
TmpBody->FillTopologicalEntitiesIdMapping( map );
if( map.count( DatakitFaceID ) > 0 )
{
for(
Dtk_Size_t i = 0; i < map.at( DatakitFaceID ).size(); ++i )
{
CorrespondingFacesWithGetPtr.
push_back( TmpBody->GetPtr( map.at( DatakitFaceID )[ i ] ) );
}
}
}
}
}
}