From 06696fd835f31369607ccd121dce13e5e137c191 Mon Sep 17 00:00:00 2001 From: ink Date: Thu, 4 Dec 2014 15:48:16 +0300 Subject: [PATCH] 0025518: Colors are not written to IGES 5.3 Writing of colors to IGES Face (510) and Solid (186) entities allowed since this is used by CAD systems (even if not allowed by IGES standard). Color assigned to surface, face and solid entities to ensure that different CAD systems will recognize them. Test-case for issue #25518 --- src/IGESCAFControl/IGESCAFControl_Writer.cxx | 20 ++++++++++++++-- src/IGESSolid/IGESSolid_ToolFace.cxx | 2 +- src/IGESSolid/IGESSolid_ToolManifoldSolid.cxx | 2 +- tests/bugs/iges/bug25518 | 23 +++++++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 tests/bugs/iges/bug25518 diff --git a/src/IGESCAFControl/IGESCAFControl_Writer.cxx b/src/IGESCAFControl/IGESCAFControl_Writer.cxx index 71a9bbd011..299e55c96b 100644 --- a/src/IGESCAFControl/IGESCAFControl_Writer.cxx +++ b/src/IGESCAFControl/IGESCAFControl_Writer.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -262,7 +263,7 @@ void IGESCAFControl_Writer::MakeColors (const TopoDS_Shape &S, // analyze whether current entity should get a color Standard_Boolean hasColor = Standard_False; Quantity_Color col; - if ( S.ShapeType() == TopAbs_FACE ) { + if ( S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SOLID) { if ( style.IsSetColorSurf() ) { hasColor = Standard_True; col = style.GetColorSurf(); @@ -299,6 +300,12 @@ void IGESCAFControl_Writer::MakeColors (const TopoDS_Shape &S, Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper ( FP, S ); if ( FP->FindTypedTransient ( mapper, STANDARD_TYPE(IGESData_IGESEntity), ent ) ) { ent->InitColor ( colent, rank ); + Handle(IGESSolid_Face) ent_f = Handle(IGESSolid_Face)::DownCast(ent); + if (!ent_f.IsNull()) + { + if (!ent_f->Surface().IsNull()) + ent_f->Surface()->InitColor ( colent, rank ); + } } else { // may be S was splited during shape process @@ -313,7 +320,16 @@ void IGESCAFControl_Writer::MakeColors (const TopoDS_Shape &S, for (i=1; i<=nb; i++) { Handle(Standard_Transient) t = TransientListBinder->Transient(i); ent = Handle(IGESData_IGESEntity)::DownCast(t); - if (!ent.IsNull()) ent->InitColor ( colent, rank ); + if (!ent.IsNull()) + { + ent->InitColor ( colent, rank ); + Handle(IGESSolid_Face) ent_f = Handle(IGESSolid_Face)::DownCast(ent); + if (!ent_f.IsNull()) + { + if (!ent_f->Surface().IsNull()) + ent_f->Surface()->InitColor ( colent, rank ); + } + } } } /* // alternative: consider recursive mapping S -> compound -> entities diff --git a/src/IGESSolid/IGESSolid_ToolFace.cxx b/src/IGESSolid/IGESSolid_ToolFace.cxx index 68a394d594..0c50acc45f 100644 --- a/src/IGESSolid/IGESSolid_ToolFace.cxx +++ b/src/IGESSolid/IGESSolid_ToolFace.cxx @@ -200,7 +200,7 @@ IGESData_DirChecker IGESSolid_ToolFace::DirChecker DC.Structure (IGESData_DefVoid); DC.LineFont (IGESData_DefVoid); DC.LineWeight (IGESData_DefVoid); - DC.Color (IGESData_DefVoid); + DC.Color (IGESData_DefAny); DC.SubordinateStatusRequired(1); return DC; diff --git a/src/IGESSolid/IGESSolid_ToolManifoldSolid.cxx b/src/IGESSolid/IGESSolid_ToolManifoldSolid.cxx index 58c9289f16..d2c7a3784b 100644 --- a/src/IGESSolid/IGESSolid_ToolManifoldSolid.cxx +++ b/src/IGESSolid/IGESSolid_ToolManifoldSolid.cxx @@ -183,7 +183,7 @@ IGESData_DirChecker IGESSolid_ToolManifoldSolid::DirChecker DC.Structure (IGESData_DefVoid); DC.LineFont (IGESData_DefVoid); DC.LineWeight (IGESData_DefVoid); - DC.Color (IGESData_DefVoid); + DC.Color (IGESData_DefAny); return DC; } diff --git a/tests/bugs/iges/bug25518 b/tests/bugs/iges/bug25518 new file mode 100644 index 0000000000..9b595b45a4 --- /dev/null +++ b/tests/bugs/iges/bug25518 @@ -0,0 +1,23 @@ +puts "========" +puts "OCC25518" +puts "========" +puts "" +###################################### +# Colors are not written to IGES 5.3 +###################################### + +catch {exec rm ${imagedir}/OCC25518.igs} +psphere s 10 +XNewDoc D +XAddShape D s +XSetColor D s 0 0 1 +param write.iges.brep.mode 1 +WriteIges D ${imagedir}/OCC25518.igs +ReadIges T ${imagedir}/OCC25518.igs +if {[string trim [XGetAllColors T]] != "BLUE1"} { + puts "ERROR: OCC25518 is reproduced. Color is lost." +} +XShow T +vfit +vsetdispmode 1 +set only_screen 1