Francesco Argese Mon, 06/04/2012 - 22:18 Forums: Other usage issuesHi all, is there a manner to load a .csfdb file inside a document? I'm searching something similar to IGESCAFControl_Reader or STEPCAFControl_Reader. Thanks in advance, Francesco Argese Marco Nanni Mon, 06/04/2012 - 23:10 Hello Francesco, have a look in the sample import/export. The tool is capable to import/export csfdb as well. Cheers, Marco. Log in to post comments Francesco Argese Tue, 06/05/2012 - 18:39 Hello Marco, I've already seen in import/export sample but it shows only how to load a csfdb as a TopTools_HSequenceOfShape and not as a document. I'm trying to load it in a document in order to have advantages of OCAF. Francesco Log in to post comments Marco Nanni Tue, 06/05/2012 - 20:10 Hello Francesco, In StdResoucce folder, there is nothing about such file extension (no schema and no storage/retrival drivers guid). I believe there is no provided application able to load it as document, but I am no so much expert to give you a final advice. Marco. Log in to post comments Patrik Mueller Wed, 06/06/2012 - 12:29 Hi, here's a snippet sample. I use it to transfer the data after reading the csfdb file. Hope it helps: bool XDEImporterCSFDB::Transfer(Handle_TDocStd_Document theDocument) { bool result = BaseXDEImporter::Transfer(theDocument); if (result) { if (!m_pStorageData.IsNull()) { Handle(Storage_HSeqOfRoot) roots = m_pStorageData->Roots(); Handle(Standard_Persistent) p; Handle(Storage_Root) r; Handle(PTopoDS_HShape) aPShape; Handle (XCAFDoc_ShapeTool) rootAssembly = XCAFDoc_DocumentTool::ShapeTool (theDocument->Main()); //Handle (XCAFDoc_ColorTool) colors = XCAFDoc_DocumentTool::ColorTool (theDocument->Main()); Handle (XCAFDoc_LayerTool) layers = XCAFDoc_DocumentTool::LayerTool (theDocument->Main()); TDF_Label layerLabel = layers->AddLayer("Base_Layer"); //Quantity_Color Col (Quantity_NOC_NAVYBLUE/*Quantity_NOC_GRAY18*/); //XCAFDoc_ColorType ctype = XCAFDoc_ColorGen; int nbEntries = roots->Length(); for (int i = 1; i <= nbEntries ; i++ ) { r = roots->Value(i); p = r->Object(); aPShape = Handle(PTopoDS_HShape)::DownCast(p); if ( !aPShape.IsNull() ) { PTColStd_PersistentTransientMap aMap; TopoDS_Shape aTShape; MgtBRep::Translate(aPShape,aMap,aTShape, MgtBRep_WithTriangle); if (!aTShape.IsNull()) { TDF_Label aLabel = rootAssembly->AddShape(aTShape, false); TDataStd_Name::Set (aLabel, r->Name()); //colors->SetColor ( aLabel, Col, ctype ); layers->SetLayer(aLabel, layerLabel); } } } AddDefaultMaterialForEmptyMaterialList(theDocument); // add a color Greets, Patrik Log in to post comments
Mon, 06/04/2012 - 23:10
Hello Francesco,
have a look in the sample import/export.
The tool is capable to import/export csfdb as well.
Cheers,
Marco.
Tue, 06/05/2012 - 18:39
Hello Marco,
I've already seen in import/export sample but it shows only how to load a csfdb as a TopTools_HSequenceOfShape and not as a document.
I'm trying to load it in a document in order to have advantages of OCAF.
Francesco
Tue, 06/05/2012 - 20:10
Hello Francesco,
In StdResoucce folder, there is nothing about such file extension (no schema and no storage/retrival drivers guid).
I believe there is no provided application able to load it as document, but I am no so much expert to give you a final advice.
Marco.
Wed, 06/06/2012 - 12:29
Hi,
here's a snippet sample. I use it to transfer the data after reading the csfdb file. Hope it helps:
bool XDEImporterCSFDB::Transfer(Handle_TDocStd_Document theDocument)
{
bool result = BaseXDEImporter::Transfer(theDocument);
if (result)
{
if (!m_pStorageData.IsNull())
{
Handle(Storage_HSeqOfRoot) roots = m_pStorageData->Roots();
Handle(Standard_Persistent) p;
Handle(Storage_Root) r;
Handle(PTopoDS_HShape) aPShape;
Handle (XCAFDoc_ShapeTool) rootAssembly = XCAFDoc_DocumentTool::ShapeTool (theDocument->Main());
//Handle (XCAFDoc_ColorTool) colors = XCAFDoc_DocumentTool::ColorTool (theDocument->Main());
Handle (XCAFDoc_LayerTool) layers = XCAFDoc_DocumentTool::LayerTool (theDocument->Main());
TDF_Label layerLabel = layers->AddLayer("Base_Layer");
//Quantity_Color Col (Quantity_NOC_NAVYBLUE/*Quantity_NOC_GRAY18*/);
//XCAFDoc_ColorType ctype = XCAFDoc_ColorGen;
int nbEntries = roots->Length();
for (int i = 1; i <= nbEntries ; i++ )
{
r = roots->Value(i);
p = r->Object();
aPShape = Handle(PTopoDS_HShape)::DownCast(p);
if ( !aPShape.IsNull() )
{
PTColStd_PersistentTransientMap aMap;
TopoDS_Shape aTShape;
MgtBRep::Translate(aPShape,aMap,aTShape, MgtBRep_WithTriangle);
if (!aTShape.IsNull())
{
TDF_Label aLabel = rootAssembly->AddShape(aTShape, false);
TDataStd_Name::Set (aLabel, r->Name());
//colors->SetColor ( aLabel, Col, ctype );
layers->SetLayer(aLabel, layerLabel);
}
}
}
AddDefaultMaterialForEmptyMaterialList(theDocument); // add a color
Greets,
Patrik