Thursday, June 11, 2009

STEP writing

Fixed the STEPControl_Writer.Write() method. Rebuilt the wrappers and uploaded on SVN.
The following code dumps a box on disk:

OCSTEPControl_Writer aWriter = new OCSTEPControl_Writer();
OCTopoDS_Shape shape = new OCBRepPrimAPI_MakeBox(200.0, 150.0, 100.0).Shape();
aWriter.Transfer(shape, OCSTEPControl_StepModelType.STEPControl_ShellBasedSurfaceModel, true);
OCIFSelect_ReturnStatus status = aWriter.Write("C:/sharptest.step");

Implemented by hand the wrapper for the method, solved the problem by allocating a char* buffer where copied the String passed from C#, with this buffer called the native method and released the buffer at the end. Previously the code was just pinning and passing the internal pointer to String:

Standard_CString OCConverter::StringToStandardCString(System::String^ text)
{
pin_ptr textPtr = PtrToStringChars(text);
return TCollection_AsciiString((Standard_ExtString)textPtr).ToCString();
} // OCConverter::ToStandardCString


This method is used at all the String to char* conversions. Will have to think if this functionality is ok and why in the Write() case the internal pointer was overridden when memory was requested from the OpenCascade memory pool by some other object.

3 comments:

entery said...

Amazing!
Very good work..
Im so going to download this :)

I told you it was something wrong with some of the wrapper packages ;)

Anyway.. if its of any interest I will, (when I got some more time), try to look on the other formats like stl and iges. I know there is an issue with the memory allocation for the compiling/linking process. But I beleive it can get solved by some boot.ini modifications.

I really appreciate all the work you guys putting down into this wrapper.
It's very cool and so much better than working in the C++ enviroment.

:)

bxtrx said...

Probably all the Strings passed internally from C# have this problem. I will have to look again at how the OpenCascade memory pool works and fix the problem, I forgot these details.
It's good that all the conversion helpers are located on Converter.cpp maybe I can find a better solution to reimplement that code. I can't allocate there buffers as I did at STEPControl_Writer because I have no way to release them.

Guido said...

Hi NaroCAD developers,

I am missing Geom_Surfce the D0,D1 functions in the .NET wrappers to get points on normals to surfaces?

Can anyone tell me what I must do to make this available?

Many thanks, Guido