// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-
#include <IGESCAFControl.hxx>
#include <IGESCAFControl_Writer.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESGraph_Color.hxx>
#include <IGESGraph_DefinitionLevel.hxx>
#include <IGESSolid_Face.hxx>
+#include <IGESBasic_Name.hxx>
#include <NCollection_DataMap.hxx>
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
+#include <TCollection_HExtendedString.hxx>
#include <TColStd_HSequenceOfExtendedString.hxx>
#include <TDataStd_Name.hxx>
#include <TDF_ChildIterator.hxx>
STool->GetFreeShapes ( labels );
return Transfer (labels);
}
-
-//=======================================================================
-//function : Perform
-//purpose :
-//=======================================================================
-Standard_Boolean IGESCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc,
- const Standard_CString filename)
-{
- if ( ! Transfer ( doc ) ) return Standard_False;
- return Write ( filename ) == IFSelect_RetDone;
-}
-
//=======================================================================
-//function : Perform
+//function : Transfer
//purpose :
//=======================================================================
-Standard_Boolean IGESCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc,
- const TCollection_AsciiString &filename)
+Standard_Boolean IGESCAFControl_Writer::Transfer (const TDF_Label& label)
{
- if ( ! Transfer ( doc ) ) return Standard_False;
- return Write ( filename.ToCString() ) == IFSelect_RetDone;
+ TDF_LabelSequence labels;
+ labels.Append( label );
+ return Transfer( labels );
}
-
+
//=======================================================================
//function : Transfer
//purpose :
return Standard_True;
}
+//=======================================================================
+//function : Perform
+//purpose :
+//=======================================================================
+
+Standard_Boolean IGESCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc,
+ const Standard_CString filename)
+{
+ if ( ! Transfer ( doc ) ) return Standard_False;
+ return Write ( filename ) == IFSelect_RetDone;
+}
+
+//=======================================================================
+//function : Perform
+//purpose :
+//=======================================================================
+
+Standard_Boolean IGESCAFControl_Writer::Perform (const Handle(TDocStd_Document) &doc,
+ const TCollection_AsciiString &filename)
+{
+ if ( ! Transfer ( doc ) ) return Standard_False;
+ return Write ( filename.ToCString() ) == IFSelect_RetDone;
+}
+
//=======================================================================
//function : WriteAttributes
//purpose :
TDF_Label L = labels.Value(i);
// collect color settings
- XCAFPrs_DataMapOfShapeStyle settings;
+ XCAFPrs_IndexedDataMapOfShapeStyle settings;
TopLoc_Location loc;
XCAFPrs::CollectStyleSettings ( L, loc, settings );
if ( settings.Extent() <=0 ) continue;
//=======================================================================
void IGESCAFControl_Writer::MakeColors (const TopoDS_Shape &S,
- const XCAFPrs_DataMapOfShapeStyle &settings,
+ const XCAFPrs_IndexedDataMapOfShapeStyle &settings,
XCAFPrs_DataMapOfStyleTransient &colors,
TopTools_MapOfShape &Map,
const XCAFPrs_Style &inherit)
// check if shape has its own style (or inherits from ancestor)
XCAFPrs_Style style = inherit;
- if ( settings.IsBound(S) ) {
- XCAFPrs_Style own = settings.Find(S);
+ if ( settings.Contains(S) ) {
+ XCAFPrs_Style own = settings.FindFromKey(S);
if ( own.IsSetColorCurv() ) style.SetColorCurv ( own.GetColorCurv() );
if ( own.IsSetColorSurf() ) style.SetColorSurf ( own.GetColorSurf() );
+ style.SetMaterial (own.Material());
}
// analyze whether current entity should get a color
hasColor = Standard_True;
col = style.GetColorSurf();
}
+ else if (!style.Material().IsNull()
+ && !style.Material()->IsEmpty())
+ {
+ hasColor = Standard_True;
+ col = style.Material()->BaseColor().GetRGB();
+ }
}
else if ( S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE ) {
if ( style.IsSetColorCurv() ) {
Handle(TCollection_HAsciiString) str =
new TCollection_HAsciiString ( col.StringName ( col.Name() ) );
colent = new IGESGraph_Color;
- colent->Init ( col.Red() * 100., col.Green() * 100., col.Blue() * 100., str );
+ NCollection_Vec3<Standard_Real> aColor_sRGB;
+ col.Values (aColor_sRGB.r(), aColor_sRGB.g(), aColor_sRGB.b(), Quantity_TOC_sRGB);
+ colent->Init ( aColor_sRGB.r() * 100., aColor_sRGB.g() * 100., aColor_sRGB.b() * 100., str );
AddEntity ( colent );
colors.Bind ( c, colent );
}
Igesent->InitLevel( 0, localIntName );
}
#ifdef OCCT_DEBUG
- else cout << "Warning: Can't find entity for shape in mapper" << endl;
+ else std::cout << "Warning: Can't find entity for shape in mapper" << std::endl;
#endif
}
}
anAsciiName->SetValue (aNameLength+1, IsAnAscii (aName.Value (aCharPos)) ? (Standard_Character )aName.Value (aCharPos) : '?');
}
anIGESEntity->SetLabel (anAsciiName);
+
+ // Set long IGES name using 406 form 15 entity
+ Handle(IGESBasic_Name) aLongNameEntity = new IGESBasic_Name;
+ Handle(TCollection_HExtendedString) aTmpStr = new TCollection_HExtendedString(aName);
+ aLongNameEntity->Init(1, new TCollection_HAsciiString(aTmpStr, '_'));
+
+ anIGESEntity->AddProperty(aLongNameEntity);
+ AddEntity(aLongNameEntity);
}
}