Annotating 2D entities in 3D models - e.g. Step AP 203 ed2 GD&A

Hi everyone!

I was wondering if it is possible to annotate 2D entities like faces, edges or vertices with OCC? One option would be to use STEP AP203 Ed2 FT&D or GD&A style annotations.

What I would like to do is to manually add annotations as unique labels to certain entities of a 3D part and to use these annotations at a later point to adress the specific entities e.g. for automated modeling operations. So, the user should be able to annotate a part and based on these annotations my system (using OCC) can then perform further steps without user interaction. I hope I made myself clear.

As far as I see it OCC does not support Step GD&A annotations. Am I right? If so, does anyone have an idea how such annotations could be done?

thomas's picture

Oh, and just to be clear: I just want some textual annotations, no real tolerance annotations needed.

Forum supervisor's picture

Dear Thomas, OCCT provides a way to associate additional data with shapes through OCAF in general, and in particular XDE component (please, see its user's guide) provides a way to define assemblies and associate names, colors, and other data to shapes. These data can be exported to / imported from STEP. There is also minimal support of GD&T (dimensional tolerances, not annotations), but this has not yet been documented in the user's guide.

Pawel's picture

Dear Thomas,

some time ago I had to implement GD&T visualization using OCCT (GD&T / FT&A - whatever you call them - come from an external source/file using a 3rd party product). The solution I ended up with was to use the XDE assembly structure for the geometrical data. The annotations were stored separately using OCAF. Unfortunately, I had to store the shapes the annotations refer to separately (i.e. redundantly). There were two reasons for that:

1. It is possible to attach data to individual geometrical features of TopoDS_Shapes in XDE (like colors), I guess, but this is not well documented and I could not find any samples. So it was necessary to dig through the OCCT code, which isn't that easy.

2. The current implementation of XDE has some problems: visualization of 'free shapes' get recomputed very often so it was of advantage to store the annotated faces/edges separately in order to be able to manage (show, highlight etc.) them without having to cope with the recomputation of the visualization.

Hope this helps
Pawel

thomas's picture

Thanks to both of you for your replies!
So it seems possible but probably requires some work(around). I found the documentation for Step and XDE (https://bitbucket.org/sboz/wendel/src/df14a63bb6a2c421cba54f3183d85a1765...) and will read through it. I am especially interested in what data can be stored using XDE. I will definitely need assemblies and associate names plus textual annotations of 2D entities.

@Pawel: In what form did you store the separately stored entities (faces/edges incl. annotations) and how did you merge it with the geometrical data? I do not need an exact description, just a pointer in the right direction.

Agian, thanks for all further replies!

Thomas

Pawel's picture

Hi Thomas,

my structure looks basically like this:

Let's say I have an GD&T label in my OCAF structure. Each label under that one is an annotation. Each annotation has some attributes (text, identifiers of the referenced geometries etc.) and maybe sub-labels (depending on the annotation type).

Then there is another label storing all the referenced TopoDS_Shapes (as TNaming_NamedShape attributes, copied from the original shape, assembly etc.) created when importing the model/assembly. The tag number of each label is equal to the identifier this shapes is referenced by.

In my case the shapes do not change at all after the import so I don't have any inconsistencies. But the above approach might not be the best one if you intend to edit your annotations and/or shapes.

Pawel

dinesh.gavsane_156255's picture

Hi,

I am trying to display annotation at sharp connected face edge. I would like to display image annotation I have attached the annotations.png

Is it possible to have some special characters in image format to imbed in OCC annotation. Or is there any we can just mention the image path to show the special annotations.

Thanks,

Dinesh

Attachments: 
Kirill Gavrilov's picture

What do you call here by "OCC annotation"?
If you are talking just about 3D Viewer in general (like AIS_Point), then your kind of icons can be displayed as point sprites (Graphic3d_AspectMarker3d constructor from Image_PixMap).

dinesh.gavsane_156255's picture

Hi,

Thanks for the reply. OCC annotation means I am trying to give special symbols/image/icons as annotations to the connecting edge of two faces. I can give "text annotation" by using Graphic3d_AspectText3d but it does not support special symbols in text format. So I was looking if its possible to display icons/images as a annotation. I hope this clears my requirement. If you have any idea how to make it Can you please give me some example?

Thanks in advance!

Thanks,

Dinesh

Kirill Gavrilov's picture

Use marker to show a custom icon.
Text may display only symbols defined in a font - so alternatively you may choose a font and symbols in it that you expect.
As there are a lot of funny symbols in UNICODE nowadays, including emoji, there is a chance that you will find some.
Sometimes applications use special fonts for displaying non-standard symbols.

dinesh.gavsane_156255's picture

Hi kirill,

Thank you ! I will try with marker. I guess only thing I need to look for is "Image_PixMap" initialization with icon bitmap image with given path of icon.

Thanks,

Dinesh

dinesh.gavsane_156255's picture

Hi Kirill,

Do you know how to use "Image_PixMap" with icon paths. I am having some icons stored at C:\ drive and want to refer that icons using "Image_PixMap".

Thanks,

Dinesh

Kirill Gavrilov's picture

Take a look onto class Image_AlienPixMap, which is subclass of Image_PixMap.

dinesh.gavsane_156255's picture

Thank you Kiril. I am able to load icon image.

Thanks,

Dinesh

dinesh.gavsane_156255's picture

One more query actually I want to change the color of icon from the image file ? Is this possible ? I have seen the Image_PixMap class there are some methods to know the pixel color but I didn't find any to set the color.

Please let me know if is there any solution to make it work.

Thank you,

Dinesh.

Kirill Gavrilov's picture

Check the "Markers in 3d viewer" sample within Draw Harness to see various options.

Imported grayscale image is considered as color-less transparency levels, so that they will take a color of marker aspect.
RGB(A) images are considered as colored, so that only dynamic highiglighting presentation will be displayed with modified color
using grayscale image generated by Graphic3d_MarkerImage::GetImageAlpha() tool.

You may write your own code for processing RGB(A) images in the way you need.

dinesh.gavsane_156255's picture

Hi,

I am using Graphic3d_AspectText3d to display text annotation. I am facing some issues when we do zoom-in  and zoom-out I am not able to see annotations and the size of the annotations as well not appropriate. Please see below code snippet of display text annotation.

Please let me know if I am doing a correct thing or is there anything missing. Thanks in advance.

Thanks,

Dinesh

///////////////

TextInfo as defined as below,

TextInfo textInfo = new SXTextInfo();
textInfo.Color = QuantityNameOfColor.Quantity_NOC_MAGENTA1;
textInfo.IsZoomable = false;
textInfo.Height = textInfo.Height/10.0;
textInfo.TextFontAspect = TextFontAspect.Font_FA_Bold;
textInfo.TextPath = Graphic3dTextPath.Graphic3d_TP_UP; 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

       public void DisplayTextAnnotation(string text, double[] location, TextInfo textInfo)
        {
            Quantity_NameOfColor color = (Quantity_NameOfColor)textInfo.Color;
            Aspect_TypeOfStyleText aspectStyle = (Aspect_TypeOfStyleText)textInfo.AspectStyle;
            Graphic3d_HorizontalTextAlignment horizontalTextAlignment = (Graphic3d_HorizontalTextAlignment)textInfo.HorizontalAlignment;
            Graphic3d_VerticalTextAlignment verticalTextAlignment = (Graphic3d_VerticalTextAlignment)textInfo.VerticalAlignment;
            Graphic3d_TextPath textPath = (Graphic3d_TextPath)textInfo.TextPath;

            Graphic3d_AspectText3d aTextAspect = new Graphic3d_AspectText3d();
            aTextAspect.SetTextZoomable(textInfo.IsZoomable);
            aTextAspect.SetColor(new Quantity_Color(color));
            aTextAspect.SetTextAngle(textInfo.Angle);
            aTextAspect.SetFont(textInfo.Font);
            aTextAspect.SetStyle(aspectStyle);

            Graphic3d_Group textGroup = Prs3d_Root.CurrentGroup(prsPartNamePresentation);
            textGroup.SetPrimitivesAspect(aTextAspect);

            Graphic3d_Vertex aPoint = OCCConvertor.Graphic3d_Vertex(location);
            textGroup.Text(text, aPoint, textInfo.Height, textInfo.Angle, textPath, horizontalTextAlignment, verticalTextAlignment, true);            
        }