Mon, 06/20/2016 - 18:16
Hi, I have got an issue with STEP writer,
I have updated my Opencascade version and color are not exported.
On version 6.7.1 everything works well
but with version 6.8.0 and 6.9.3 the color writing don't work.
I search on release note for a regression or a bug but i don't find anything... Am I missing something ?
Here is my code snippet :
.cpp :
// Application and document creation
myApp_ = XCAFApp_Application::GetApplication();
myApp_->NewDocument( "MDTV-XCAF", aDoc_);if ( !XCAFDoc_DocumentTool::IsXCAFDocument (aDoc_) )
return -1;// Tools
myAssembly_ = XCAFDoc_DocumentTool::ShapeTool( aDoc_->Main() );
myColors_ = XCAFDoc_DocumentTool::ColorTool( aDoc_->Main() );
myLayers_ = XCAFDoc_DocumentTool::LayerTool( aDoc_->Main() );//-----------------------------------------------------
// STEP Content{
BRep_Builder builder;// Builder
TopoDS_Compound comp;
builder.MakeCompound(comp);std::vector<TopoDS_Shape> subshapevec;
std::vector<CBPoint> colvec;
std::vector<std::string> namevec;
// Retrieve shape informations
TopoDS_Shape shape = ...;
// RGB between 0 and 255
CBPoint couleur = ...;
// Browse topods_shape
TopExp_Explorer expSolid;
for ( expSolid.Init( shape, TopAbs_SOLID, TopAbs_COMPSOLID); expSolid.More(); expSolid.Next())
{
builder.Add( comp, expSolid.Current());
subshapevec.push_back(expSolid.Current());
colvec.push_back(couleur);
namevec.push_back(...);
}
// Label creation
TDF_Label lComp = myAssembly_->AddShape( comp, true);
TCollection_ExtendedString aName(...);
TDataStd_Name::Set (lComp, aName);
// Ajout des elements.
for (int i = 0; i < (int) subshapevec.size(); i++)
{
// SubShape
TopAbs_ShapeEnum type = subshapevec[i].ShapeType();
TDF_Label lFils = myAssembly_->AddSubShape (lComp, subshapevec[i]);// Names
TCollection_ExtendedString bName(namevec[i]);
TDataStd_Name::Set (lFils, bName);// Colors
Quantity_Color couleur (
((double) colvec[i].x) / 255.,
((double) colvec[i].y) / 255.,
((double) colvec[i].z) / 255.,
Quantity_TOC_RGB);
myColors_->SetColor(lFils, couleur, XCAFDoc_ColorGen);// Also try this
//myColors_->SetColor(subshapevec[i], couleur, XCAFDoc_ColorGen);subshapevec[i].Nullify();
}
}//-----------------------------------------------------
// Step writerSTEPControl_StepModelType mode = STEPControl_AsIs;
STEPCAFControl_Writer writer;writer.SetColorMode(Standard_True);
if ( ! writer.Transfer ( aDoc_, mode ) )
return -1;
else
IFSelect_ReturnStatus stat = writer.Write( fileName );myApp_->Close(aDoc_);
return 1;
.h :
Handle(XCAFApp_Application) myApp_;
Handle(TDocStd_Document) aDoc_;
Handle(XCAFDoc_ShapeTool) myAssembly_;
Handle(XCAFDoc_ColorTool) myColors_;
Handle(XCAFDoc_LayerTool) myLayers_;
Tue, 06/21/2016 - 07:52
Dear Lucas,
We have sent to you a personal message - please, check your mailbox.
Best regards,
Forum supervisor
Wed, 01/30/2019 - 02:46
I have the same issue in the current 7.3 version. Can I please know what can I do to write colors? Thanks!
Wed, 08/09/2023 - 08:26
I have the same issue in 7.7.0 version. Is there any way I can solve the problem?
Wed, 08/09/2023 - 10:39
Hello, color to which label skipped? Root label or some of the child?
Best regards, Dmitrii.