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

WriteFile is not member of IGESCAFControl_Reader

James D.'s picture
Forums: 

Hi,
I have problems to read and write IGES files with colors. for example this: error in vc9: WriteFile is not member of IGESCAFControl_Reader
I look in the OCCT Documentation but can not find WriteFile ...

James D.'s picture

How to read a iges file:

IGESCAFControl_Reader myIgesReader;
myIgesReader.ReadFile("c:\\Develop\\Samples\\Sample_IGES_Alt.igs");
myIgesReader.SetColorMode( Standard_True );
myIgesReader.SetNameMode( Standard_True );
myIgesReader.SetLayerMode( Standard_True );

TopoDS_Shape aBottle = myIgesReader.OneShape();

James D.'s picture

Hi,
now I can read one IGES file, but how to read two iges files and write this two files in one iges file?

like this?

// Read file 1
Handle(XCAFApp_Application) anApp = XCAFApp_Application::GetApplication();
Handle(TDocStd_Document) aDoc;
anApp->NewDocument("XmlXCAF", aDoc);

IGESCAFControl_Reader myIgesReader;
Standard_Integer nIgesFaces,nTransFaces;
IFSelect_ReturnStatus status = myIgesReader.ReadFile(argv[1]);

if (status == IFSelect_RetDone)
{
Handle(TColStd_HSequenceOfTransient) myList = myIgesReader.GiveList("iges-faces");

// Übersetzt "MyList" und erhält die Ergebnisse als OpenCASCADE-Form
nIgesFaces = myList->Length();
nTransFaces = myIgesReader.TransferList(myList);
cout printf("\n\nThe file was successfully read.\n\n");
// Wird an die Funktion vom Datentype "TopoDS_Shape" zurückgegeben

}

Standard_Boolean result = myIgesReader.Transfer(aDoc);
Handle(XCAFDoc_ShapeTool) myShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
Handle(XCAFDoc_ColorTool) myColorTool = XCAFDoc_DocumentTool::ColorTool(aDoc->Main());

TDF_LabelSequence roots;
myShapeTool->GetFreeShapes(roots);

TDF_Label rootLabel;
rootLabel = roots.Value(1);

Quantity_Color col(0.0f,1.0f,0.0f,Quantity_TOC_RGB);

TDF_Label aColorLabel = myColorTool->AddColor(col);
myColorTool->SetColor(rootLabel, aColorLabel, XCAFDoc_ColorSurf);

Quantity_Color returnCol;
myColorTool->GetColor(rootLabel,XCAFDoc_ColorSurf,returnCol);

TopoDS_Shape aBottle = myIgesReader.OneShape();

// Read file 2
Handle(XCAFApp_Application) anApp2 = XCAFApp_Application::GetApplication();
Handle(TDocStd_Document) aDoc2;
anApp->NewDocument("XmlXCAF2", aDoc2);

myIgesReader.ReadFile(argv[2]);

Handle(TColStd_HSequenceOfTransient) myList = myIgesReader.GiveList("iges-faces");

// Übersetzt "MyList" und erhält die Ergebnisse als OpenCASCADE-Form
nIgesFaces = myList->Length();
nTransFaces = myIgesReader.TransferList(myList);
cout printf("\n\nThe file was successfully read.\n\n");
// Wird an die Funktion vom Datentype "TopoDS_Shape" zurückgegeben

Handle(XCAFDoc_ShapeTool) myShapeTool2 = XCAFDoc_DocumentTool::ShapeTool(aDoc2->Main());
Handle(XCAFDoc_ColorTool) myColorTool2 = XCAFDoc_DocumentTool::ColorTool(aDoc2->Main());

TDF_LabelSequence roots2;
myShapeTool->GetFreeShapes(roots2);

TDF_Label rootLabel2;
rootLabel2 = roots2.Value(1);

Quantity_Color col2(0.0f,1.0f,0.0f,Quantity_TOC_RGB);

TDF_Label aColorLabel2 = myColorTool2->AddColor(col2);
myColorTool2->SetColor(rootLabel2, aColorLabel2, XCAFDoc_ColorSurf);

Quantity_Color returnCol2;
myColorTool2->GetColor(rootLabel2,XCAFDoc_ColorSurf,returnCol2);

TopoDS_Shape aBottle2 = myIgesReader.OneShape();

IGESCAFControl_Writer aWriter;
aWriter.SetColorMode(true);
aWriter.SetNameMode(true);
aWriter.Transfer(aDoc);
aWriter.Transfer(aDoc2);
aWriter.Write(argv[3]);

}