For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Layers with IGES file

Hilaire's picture
Forums: 

Hello,

I built some geometrical objects and I would like to put each one into a particular layer in an iges file in order to display object associated to a given layer. How can I do that ?

Thank in advance for your help

Bruno

Rob Bachrach's picture

If you wish to control things like layers and colors in your IGES file, you probably want to use IGESCAFControl_Writer. You start by creating a document in the XCAFApp_Application and adding your geometries using the XCAFDoc_ShapeTool. You can then use the XCAFDoc_LayerTool to create your layers and apply them to the labels of your shapes. Finally, transfer the file with the IGESCAFControl_Writer.

You can find more information on this in the Extended Data Exchange (XDE) user guide in the OCC documentation.

Hilaire's picture

Hello,

Following the XDE user guide, I tried to build an IGES file including Color and Layer for a shape. The file is created but it seems to not contain any notion of layer nor color. Here is my program :

IGESControl_Controller::Init();

IGESCAFControl_Writer igesWriter;
igesWriter.SetLayerMode(true);
igesWriter.SetColorMode(true);
Handle(TDocStd_Document) aDoc;
getApp()->NewDocument( "XmlOcaf", aDoc );
Handle(XCAFApp_Application) anApp = XCAFApp_Application::GetApplication();
anApp->NewDocument("MDTV-XCAF",aDoc);

// The shape
Handle(XCAFDoc_ShapeTool) myAssembly = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
TDF_Label rootLabel = aDoc->Main().FindChild( 1, true );
TDF_Label aLabel = TDF_TagSource::NewChild( rootLabel );
myAssembly->UpdateAssembly(aLabel);
TopoDS_Shape myshape = BRepPrimAPI_MakeBox( 10, 10 , 10 ).Solid();
myAssembly->SetShape(aLabel,myshape);

// Color
Handle(XCAFDoc_ColorTool) myColors = XCAFDoc_DocumentTool::ColorTool(aDoc->Main());
TDF_Label colLabel = myColors->AddColor(Quantity_Color(Quantity_NOC_BLUE1));
myColors->SetColor(myshape,colLabel, XCAFDoc_ColorGen);

// Layer
myLayers = XCAFDoc_DocumentTool::LayerTool(aDoc->Main());
TDF_Label layerLabel = myLayers->AddLayer("TEST");
myLayers->SetLayer(myshape,layerLabel);

Standard_Boolean w = false;
w = igesWriter.Transfer(aDoc);
Standard_CString f = "C:\\test3.igs";
w = igesWriter.Write(f);

Does anyone have an idea what is wrong with that?

Thank in advance

Bruno

Rob Bachrach's picture

I just ran your code (as-is) and loaded the resulting IGES file into the Draw test harness (using ReadIges from the XDE package). The colors and layers appear to read in fine. Perhaps this has something to do with the program you are using to read and interrogate the IGES file.

Hilaire's picture

Dear Rob,

I loaded the generated file with Rhinoceros 4.0 and the layer's name is Level 0 instead of the name I gave "TEST" and the color is black instead of blue. It seems it is a default layer and a default color. Do you see the right color and layer using draw ?
Normally, I should see the name of the layer into the Iges file opened with a text editor, isn't it?

Bruno

Rob Bachrach's picture

Bruno,

When viewing in DRAW, I do see the correct color and there is a layer assigned.

I was both right and wrong. The code is assigning the color and layer, but is not creating an entry naming the layer. If you check the IGES file, you will see that 6 trimmed surfaces (144) and 12 lines (110) are assigned a color (field 13) based on your code. The color number equates to standard color indexes in the IGES standard. Those same entities have the level (or layer, field 5) set to 1 for your layer. There is, however, no 406 records to name the layer. DRAW simply shows the name of the layer as "1".

Rob

Mathias Neyer's picture

and how could a layer be named easily?? do i have to modify the IGES file manually (omg beware!)

Thanks in advance
mathias

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.