Friday, June 5, 2009

STEP wrappers

Thanks to one of our contributors we received wrappers for STEP functionality that are now included in the wrapper package. The newly compiled OCWrappers.dll is uploaded on SVN on the \trunk\wrappers\builds\release\ and also on the \trunk\narocad\Lib\. The Naro seems to work well with the new package.
Thanks again for the help to the user "entery".

Made some test code to see how it works, succeeded to load and display successfully the "screw.step" sample file from OpenCascade. When tried to write back the same shape it didn't work, Transfer() succeeded but Write(fileName) failed. It shouldn't be a wrapper problem, but this can be tested only by verifying the code against the same code implemented in C++.

Added also a test method in the test codes STEPLoadingTest():

// Load a STEP file and display it
OCSTEPControl_Reader aReader = new OCSTEPControl_Reader();
String fileName = @"c:\screw.step";

OCIFSelect_ReturnStatus status = aReader.ReadFile(fileName);

Assert.IsTrue(status == OCIFSelect_ReturnStatus.IFSelect_RetDone, "Invalid return status");

aReader.WS().MapReader().SetTraceLevel(2); // increase default trace level

bool failsonly = false;
aReader.PrintCheckLoad(failsonly, OCIFSelect_PrintCount.IFSelect_ItemsByEntity);

// Root transfers
int nbr = aReader.NbRootsForTransfer();
aReader.PrintCheckTransfer(failsonly, OCIFSelect_PrintCount.IFSelect_ItemsByEntity);

for (int n = 1; n <= nbr; n++)
{
bool ok = aReader.TransferRoot(n);
} // Collecting resulting entities

int nbs = aReader.NbShapes();
Assert.IsTrue(nbs > 0, "no shapes loaded");

OCTopTools_HSequenceOfShape aSequence = new OCTopTools_HSequenceOfShape();
for (int i = 1; i <= nbs; i++)
{
aSequence.Append(aReader.Shape(i));
}

OCAIS_Shape aisShape;
for (int i = 1; i <= aSequence.Length(); i++)
{
aisShape = new OCAIS_Shape(aSequence.Value(i));
_context3d.SetDisplayMode(aisShape, 1, false);
_context3d.Display(aisShape, false);
_context3d.SetCurrentObject(aisShape, false);
}

_context3d.UpdateCurrentViewer();
_view3d.FitAll(0.01, false, true); Thread.Sleep(10000);
_context3d.RemoveAll(true);

OCSTEPControl_Writer aWriter = new OCSTEPControl_Writer();
for (int i = 1; i <= aSequence.Length(); i++)
{
status = aWriter.Transfer(aSequence.Value(i), OCSTEPControl_StepModelType.STEPControl_ShellBasedSurfaceModel, true);
Assert.IsTrue(status == OCIFSelect_ReturnStatus.IFSelect_RetDone, "Invalid return status");
}

String outputFileName = @"c:\test.step";
status = aWriter.Write(outputFileName);

Assert.IsTrue(status == OCIFSelect_ReturnStatus.IFSelect_RetDone, "Invalid return status");

No comments: