Attribute Definitions   

<<< Identifying Application Data Chapters Attributes >>>

Contents

[back to top]


94.1 Introduction

Attributes are used to supplement the Parasolid data structure by attaching additional data to Parasolid entities. The attribute definition has properties which define the attribute’s behaviour when the entity to which it is attached is involved in modeling operations, by setting the:

These properties determine the normal processing which Parasolid applies to the attributes, as described in Chapter 95, “Attributes”. However, the application can specify an alternative processing methodology using callback functions invoked according to the:

 

Related Topics:

[back to top]


94.2 Attribute definitions

Attribute definitions are used to specify the behaviour of individual attributes. Each definition contains:

 

Note: Attributes cannot be attached to orphan geometry regardless of the entity class. See Section 95.5.2, “Modeling operations and attributes attached to geometry”, for more information.

See Section 95.1, “Introduction”, for more information.

Attribute fields can also be given names if you wish. See Section 94.2.1, “Using named fields”, for details.

Attribute definitions belong to the session, they are not associated with any partition. Once created, an attribute definition cannot be changed or deleted. In particular, attribute definitions are not deleted by rolling back the session to before they were created - they continue to exist.

 

Warning: Once created, you must never try to change an attribute definition. If you want to make changes to attribute definitions in your product, you should create a new attribute definition using a new string identifier for the name, and identify it as a “new” version of an existing attribute definition using any system you find convenient. See Section 94.2.3, “Attribute definition names”, for more information.

Within a session, many different attribute definitions may be created provided that they all have distinct names.

94.2.1 Using named fields

There are two complementary ways of handling attribute fields in Parasolid.

Standard attribute definitions, created using PK_ATTDEF_create, contain fields whose contents must be accessed via the number of the field, as defined in the attribute definition.

To support the distribution of Parasolid models via a Web or text-based interface, you can also define attributes that contain named fields, using PK_ATTDEF_create_2. The contents of these fields can be accessed by using the field name, meaning that you do not have to rely on the order in which fields are defined in the attribute definition.

For information on accessing the contents of a specific field in an attribute, see Section 95.2.3, “Adding to and retrieving data from attribute fields”.

94.2.2 PK functions specific to attribute definitions

The following table summarises the functions that are specific to attribute definitions.

 

Function

Description

PK_ATTDEF_create

Create an attribute definition

PK_ATTDEF_create_2

Create an attribute definition that contains named fields

PK_ATTDEF_ask

Return the standard form (PK_ATTDEF_sf_t) of an attribute definition for non-named fields. If called on an attribute definition created with PK_ATTDEF_create_2, this function returns the non-named standard form.

PK_ATTDEF_ask_2

Return the standard form (PK_ATTDEF_sf_2_t) of an attribute definition for named fields. If called on an attribute definition created with PK_ATTDEF_create, this function returns NULL for field names.

PK_ATTDEF_find

Map from an attribute name to a definition

PK_ATTDEF_is_group_closing

Ask whether the given attribute definition is a group closing attribute definition. See Section 98.7, “Closed groups” for more information.

PK_ATTDEF_set_group_closing

Sets the given attribute definition to be a group closing one. See Section 98.7, “Closed groups” for more information.

PK_ENTITY_may_own_attdef

Ask whether a given entity may own an attribute of a given definition

PK_PART_ask_all_attdefs

Get all attribute definitions anywhere in the part

PK_SESSION_ask_attdefs

Return the number of user-defined attribute definitions in the session, optionally together with the attribute definitions themselves.

94.2.3 Attribute definition names

It is recommended that all attribute definition names are prefixed with a string which relates to the application or company name. If your application automatically (and transparently) adds and removes this string as appropriate, it should never have to deal with an attribute definition on a part that is incompatible with those defined in the application.

For example, Parasolid’s system-defined attribute definitions are prefixed with “SDL/TY” to ensure they never clash with attribute definitions created by an application - the density attribute definition is called “SDL/TYSA_DENSITY”.

If two applications have an attribute definition simply called ‘Density’, but one uses an integer field and the other a double field, then the definitions are incompatible. A part created in one application fails to load into the other. The attribute definition should be given a name with a prefix specific to the application, thus avoiding conflict with attribute definitions in any other applications.

See Section 94.4, “System attribute definitions”, for a list of the other attribute definitions created by Parasolid.

If a given attribute definition actually represents a “new” version of an existing attribute definition in your application, then you can indicate this in the name of the attribute definition itself, if you wish.

94.2.3.1 Compatible attribute definitions

Two attribute definitions are compatible, that is they can inhabit the same session, when they have:

 

Note: An exception to the second rule above applies to attributes that can be owned by fins. If the only difference between two attribute definitions with the same name is that one can be owned by fins and one cannot, then they are deemed to be compatible.

This means that part files saved in versions of Parasolid earlier than 11.1 can be successfully loaded into Parasolid V12 or later without requiring any changes to the system attribute definitions. Attributes can only be attached to fins in Parasolid V11.1 or later.

94.2.3.2 Saving and receiving attribute definitions

When a part is saved, all attributes attached to entities in the part, and their definitions, are saved with the part; unused attribute definitions are not saved.

When saving a part in a format used by a previous version of Parasolid, attributes are removed from an entity if they are not supported for that entity type in that version of Parasolid. For example, saving a part in Parasolid V11.0 or earlier format removes any attributes attached to fins.

When receiving a part file, parts can only be loaded successfully if their attribute definitions are compatible with the attribute definitions in the current Parasolid session. The attribute definitions of attributes attached to entities in successfully loaded parts are created automatically.

Parts are not loaded successfully if their attribute definitions are incompatible with the definitions in the current Parasolid session. This means, for example, that two applications with incompatible ‘Density’ definitions cannot share any part with a Density attribute attached - the part fails to load.

94.2.4 Classes of attributes

All attribute definitions have a class which defines:

The modeling operations are explained in Chapter 95, “Attributes”.

 

Class

Properties

Example of use

1

Attribute is independent of the entity’s position and size

density

2

Attribute is dependent on the size of entity but is independent of its position

weight

3

Attribute is dependent on both the size and position of the entity

inertia properties

4

Attribute that transforms with the owning entity (for rigid body transforms), but is otherwise independent of the size and shape of the entity. See Section 14.2.9, “Assembly” for a description of rigid body transforms.

start point or direction of movement of the tool that cuts a face

5

Attribute that transforms with the entity providing that the entity is not changed in other ways

center of gravity

6

As for class 1, attribute is independent of physical size and position for the entity to which it is attached. However this class of attribute supports multiple values - one entity may have multiple attributes with the same definition attached.

7

As for class 4, attribute transforms with its owner (for rigid body transforms), but is otherwise independent of size and shape of the owner. However this class supports multiple values - an entity may have multiple attributes with the same definition attached.

internal

Attribute is created for internal use by Parasolid only. You cannot create definitions of this class, or attributes of any existing attribution definitions. There are no visible fields for attribute definitions of this class.

Geometric entities may only be specified as the legal owner of attributes of classes 1, 4, 6, and 7. See Section 95.5.2, “Modeling operations and attributes attached to geometry”, for more information.

[back to top]


94.3 Callback functions

Callback functions provide applications with a more powerful method of attribute processing than Parasolid’s normal attribute handling. The functions are attached to attribute definitions, and are called by Parasolid when entities with that type of attribute undergo one of the following events:

Callback functions must be registered before they can be invoked. PK_ATTDEF_register_cb registers pointers to the callback functions supplied in your application, and PK_ATTDEF_ask_callbacks returns those pointers.

 

Note: Where an entity has multiple attributes of different definitions, applications should not rely on those attributes being processed in any specific ordering.

There are two types of callback function:

Normal callbacks

These functions can modify and enquire about the attributes or other parts of a model as necessary. When a normal callback is invoked, the action it carries out replaces Parasolid’s normal attribute processing.

Read-only callbacks

These functions cannot modify the attributes or other parts of a model in any way. After a call to a read-only callback returns, Parasolid processes the attributes according to their class, in the usual way.

You use the callback_type field in the options structure for PK_ATTDEF_register_cb to specify whether a callback function is normal (PK_ATTDEF_callback_normal_c) or read-only (PK_ATTDEF_callback_read_only_c)

Every attribute definition can have several callback functions associated with it: one for each type of event. Different events can then trigger calls to different associated callback functions. Each attribute definition has a set of logical flags that determine whether or not a callback function is called when an event takes place.

PK_ATTDEF_set_callback_flags sets these callback function on/off flags, and they are returned by PK_ATTDEF_ask_callback_flags.

For an example of this functionality, see the code example in the C++\Code Examples\Application Support\Attribute Processing\Callbacks folder, located in example_applications in your Parasolid installation folder.

 

Warning: If, at any time in a Parasolid session, you have registered any normal callback functions, tag persistence behaviour will be permanently disabled for the remainder of that Parasolid session. This will apply for all modeling operations that can split an entity and then delete one of the split entities. This affects a range of operations, including booleans, imprinting, blending and local operations. For more information about tags and tag persistence see, Section 2.4.2, “Tags”.

Users and creators of Third Party Toolkits which might share a Parasolid session should carefully consider the impact of registering normal callbacks, as this will disable tag persistence for all parties.

If you are registering read-only attribute callbacks, tag persistence is not disabled. If your application callback is read-only, then it is recommended that you register it as such.

94.3.1 Events and classes

When an event occurs, a callback function is called once (only) for each attribute definition that has a callback for that event registered, and for which the participating entities have at least one attribute of that type attached.

Callback functions are called on bodies, regions, shells, faces, loops, edges, fins, vertices, geometry, transforms, groups, assemblies and instances. All events can occur to all types of entity, except that geometry, transforms, assemblies and instances are never merged or split.

The specific actions that are performed when an event occurs depend on the type of callback that is registered to the attribute definition for that event:

The existing behaviour is described in Chapter 95, “Attributes”.

 

Note: Applications should not rely on the precise sequence or number of events during a modeling operation remaining the same in future releases of Parasolid.

94.3.2 Implementing callback functions

If a normal callback function is invoked, normal Parasolid attribute processing does not take place, apart from necessary actions (namely, deleting attributes from entities which are about to be deleted). If this processing (as described in Chapter 95, “Attributes”) is required, then you must include it in the definition of the normal callback function.

Normal callback functions may call read-only Parasolid functions, and may create, modify, and delete attributes. Read-only callback functions can only call read-only Parasolid functions, and may not create, modify, or delete attributes.

Callback functions are given one or more arrays of attributes. These always have the attribute definition to which the callback function is associated.

Callback functions and flags are not transmitted by PK_PART_transmit or PK_PARTITION_transmit.

94.3.3 Callback function interface

The callbacks are invoked as follows. In each case, the list(s) of attributes passed by Parasolid only contains attributes with the relevant attribute definition.

 

Callback type

When function is called

Data passed to the function

Split

after split has occurred

  • the old entity
  • the new entity
  • all the attributes on the old entity (there are none on the new entity)

Merge

as merge is about to occur

  • the entity which survives, and its attributes
  • the entity to be deleted, and its attributes

Delete

as deletion is about to occur

  • the entity to be deleted, and its attributes

Copy

after copy has occurred

  • the original entity and its attributes
  • the copy (which has no attributes)

Transmit

at the start of the PK function doing the transmit

  • the entity and its attributes

Receive

at the end of the PK function doing the receive

  • the entity and its attributes

The interfaces to these functions are defined in Appendix G, “Attribute Callback Functions”, of the Parasolid Downward Interfaces manual.

[back to top]


94.4 System attribute definitions

There are some attribute definitions created internally by Parasolid, which have names beginning with the string “SDL/TY”. These attributes can be manipulated in the same ways as attributes with the application’s definitions.

The following definitions are provided for use by the application to attach attributes which can then be used by the application, and by various Parasolid functions:

 

Definition

Usage

SDL/TYSA_DENSITY

Body density

SDL/TYSA_REGION_DENSITY

Region density

SDL/TYSA_FACE_DENSITY

Face density

SDL/TYSA_EDGE_DENSITY

Edge density

SDL/TYSA_VERTEX_DENSITY

Vertex density

SDL/TYSA_HATCHING

Hatching

SDL/TYSA_PLANAR_HATCH

Planar hatching

SDL/TYSA_RADIAL_HATCH

Radial hatching

SDL/TYSA_PARAM_HATCH

Parametric hatching

SDL/TYSA_PARAM_NUM_HATCH

Parametric hatching (numeric control)

SDL/TYSA_INCREMENTAL_faceting

Incremental faceting

SDL/TYSA_REGION

Hidden line region

SDL/TYSA_COLOUR

Colour

SDL/TYSA_COLOUR_2

Colour

SDL/TYSA_REFLECTIVITY

Reflectivity

SDL/TYSA_TRANSLUCENCY

Translucency

SDL/TYSA_TRANSLUCENCY_2

Translucency

SDL/TYSA_LAYER

Layer

SDL/TYSA_NAME

Name

SDL/TYSA_UNAME

Name (supports Unicode)

SDL/TYSA_TRANSPARENCY

Transparency

SDL/TYSA_INVISIBLE

Invisibility

SDL/TYSA_EDGE_NO_MERGE

Non-mergeable edges

SDL/TYSA_GROUP_MERGE

Group merge behaviour

SDL/TYSA_GROUP_CONTROL

Behaviour of empty groups when owning parts are split or merged

SDL/TYSA_SCALE_FACTOR

Representing the scale factor of a part

See Appendix A, “System Attribute Definitions”, for more information on the attribute definitions created by Parasolid.

 

[back to top]

<<< Identifying Application Data Chapters Attributes >>>