Sunday, March 1, 2009

Live Update for Extrude


This is gonna be short, but is an important achievement. Extrude works lively and works nice: Click on a shape you want to extrude and dragging the mouse up-down you increase/decrease the extrude size. This is the first complex action that works lively and it is based on different working that was done last week.

What will be next:
- bug fixes (the ellipse is still not fixed in all cases)
- fillet to work lively also
- code organization to make easy adding a new action 2D or 3D.
- improve schema usage, reduce OpenCascade code needed for a new action (that will make it easier for other persons to add a brand new action)

6 comments:

entery said...

Hi,
I have a problem displaying 2D text. What would be the easiest approach here?
I've been trying the following solution, but the application fails.. :(

OCTCollection_ExtendedString str1 = new OCTCollection_ExtendedString("Test");
OCGraphic2d_GraphicObject txtObj=new OCGraphic2d_GraphicObject();
OCGraphic2d_Text t1 = new OCGraphic2d_Text(txtObj,str1,10.0,0.0,0.0,OCAspect_TypeOfText.Aspect_TOT_SOLID,0.1);
t1.SetUnderline(false);
t1.SetZoomable(true);
txtObj.Display(); // <=Exception

Best Regards

entery

ciplogic said...

Hello entery,

I did adapt your sample a bit, and I made the following change(s):
OCGraphic2d_GraphicObject txtObj=new OCGraphic2d_GraphicObject();
becomes:
OCAIS2D_InteractiveObject textObject = new OCAIS2D_InteractiveObject();

and:
context2d.Display(textObject, false);
replaces your line:
txtObj.Display();
Where context2d is your: OCAIS2D_InteractiveContext created with your 2d View.

Did it work on you?

Ciprian

entery said...

Hi Ciplogic,
Thanks for fast reply. It seems like I've been misunderstanding the use of OCGraphic2d_Text
Since im using a 3D view, with OCAIS_InteractiveContext.
Is it OCGraphic3d_AspectText3d I should use to display 2D text in a 3D view?

Sorry for the stupid questions ;o) I'm a newbee to this API..

Best Regards

entery

ciplogic said...

Hello entery,

I did not found yet (probably of course cause of my lack of free time :( ) a proper way to do it from 2D to 3D.

My natural answer is: I think yes, but I'm not so sure :)

If I will find, at a later time, I will say it, if you will find it, please say to me also. One last thing: there is a sample with fonts (that uses MFC) but as I haven't MFC installed (I have Visual C++ Express but I cannot compile the samples with OCC). You may look if you understand the code better there... sounds a good idea?

Bests,
Ciplogic

entery said...

Hi Cip,
I found a way to write 2D text in a 3D View, but im not sure if this is the right way. Anyway I does what I need..

private void WriteText(string Text, OCgp_Pnt Coord)
{
OCTCollection_ExtendedString txtStr = new OCTCollection_ExtendedString(Text);
OCgp_Pnt pntCross = Coord;
OCBRepBuilderAPI_MakeVertex vertex = new OCBRepBuilderAPI_MakeVertex(pntCross);
OCAIS_Shape shape = new OCAIS_Shape(vertex.Shape());
context.Display(shape, false);
OCPrs3d_Presentation prs3D = new OCPrs3d_Presentation(context.CurrentViewer().Viewer(), false);
OCPrs3d_TextAspect txtAspect = new OCPrs3d_TextAspect();
txtAspect.SetFont(OCGraphic3d_NameOfFont.Graphic3d_NOF_ASCII_ITALIC_TRIPLEX);
txtAspect.SetHeight(2);
txtAspect.SetSpace(20);
OCPrs3d_Text.Draw(prs3D, txtAspect, txtStr, pntCross);
prs3D.Display();
}


Do you know when the Iges / Step functions will be wrapped?
Should be very cool to be able to export to those formats ;o)

Have nice day!

Best Regards

entery

ciplogic said...

Hello entery,

Thank you for your post.

The actual wrappers ask for a lot of build time and adding some package (even for one or two and solve the compiling issues that may appear) happen to became fast a one full day work (or even more days). There is a personal attempt to create wrappers with PInvoke, and the biggest advantages will be: faster build, in a more automatically matter, probably will work with minimalist adaptation on Mono (and on Linux also) and they will be easier to be debugged. My estimate of the second project is an around one month from now task (as I do it in my free time...).

Anyway, if you need to add an extra package from currents and to rebuild yourself the wrappers, I will give to you all needed assistance. At the end please send back the update OCWrappers.dll and the extra packages you will add. (or a patch against wrappers SVN) For this email me to ciprian dot mustiata at g mail dot com. (to not have a long Q&A list on this blog).