Geometric Modeler

Geometry

The Clone and Transformation Managers

How to duplicate and/or move CGM Objects
Technical Article

Abstract

The copy and paste of geometric objects that takes into account their forward linked objects, is called cloning. This process is supported by the CATCloneManager class. Moreover, the geometric objects can also be moved, with or without copy, through a specific process handled by the CATTransfoManager class. Why these classes are needed, how they are used and how a geometric object and a manager cooperate are the main topics of this paper.


Operators to Copy or Move Objects

CATCloneManager is a class representing an operator that manages the copy and paste of a set of objects implementing the CATICGMObject interface, that is to say the persistent objects provided by the CGM offering. This operation, that also takes into account the forward linked object, is called a cloning, and is especially useful to design your own cut, copy, paste applications.

Why is there a specific class for this process, instead of a method in each class of each geometric object? This could be the easiest way to do when the objects to clone are isolated, that is, have no links with other objects. But take now two curves C1 and C2 laying on the same surface. You want to globally copy the set of the three objects C1, C2 and the underlying surface. If the copy process was at the geometric object level, the surface would be twice copied, and the resulting objects would not represent an exact image of the global initial set.

To prevent from this kind of configuration, the cloning process has a global knowledge of the objects to clone. Therefore, the role of the CATCloneManager is to federate the way to copy and paste objects and their forward linked objects. In particular, the manager clones a list of selected objects, without unnecessarily duplicating the forward common linked objects.

The same frame occurs for the transformation of geometric objects implementing the CATGeometry interface. For these objects that have a geometric meaning, the geometric transformation process follows the same way than the clone process. Hence, an object implementing the CATGeometry interface, which is a kind of CATICGMObject interface, will be geometrically transformed, with or without duplication, by the mean of a CATTransfoManager instance, which is a kind of CATCloneManager instance.

Fig1: Inheritance between CATCloneManager and CATTransfoManager
Clone1.gif (4209 bytes)

[Top]

The CATCloneManager

The programmer gives to the CATCloneManager the objects to be cloned together, by calling the CATCloneManager::Add method. All the objects must belong to the same container (a container is an object containing other objects) to be processed in a single operation.

The copy and paste is not made at the creation of the clone process, or when objects are added to the list to copy, but triggered by the CATCloneManager:Run method.

After the run, you can retrieve the cloned object corresponding to each object of the input list.

If there are topological objects to clone (topological objects are kind of geometric objects), the CATCloneManager creates, under request, the topological journal associated with the cloning operation.

The CATCloneManager instances are transient, and therefore cannot be streamed.

[Top]

Two Modes of Cloning

The cloning process can be done as a single copy or a full copy. This mode is ruled by the CATCloneManagerType:

    CatCGMSingleDuplicate
    Only copies and pastes the objects that are Added to the CATCloneManager. This is only available if the objects are copied from and pasted in the same container
    CatCGMFullDuplicate
    Copies and pastes the objects that are Added to the CATCloneManager and their forward linked objects.
    Fig2: Behavior of the duplication according to the CATCloneManagerType

    Clone2.gif (7989 bytes)

    These diagrams show the behavior of the CATCloneManager for each mode:

    C1 and C2 are two curves laying on the same Surface. Then, C1 and C2 have Surface as forward linked object.

    When C2 is selected in SingleDuplicate, its copy C2_c lays on Surface. In FullDuplicate, Surface is also duplicated in Surface_c

    When C1 and C2 are selected in SingleDuplicate, their copies C1_c and C2_c respectively lay on Surface. In FullDuplicate, their copies lay on Surface_c, the copy of Surface, that has been duplicated only once.

[Top]

A Code Sample

The following example illustrates how to copy the two curves C1 and C1 of the previous section and paste them into an other container. The result will be two new curves laying on the same new surface, with the same characteristics as the initial one.

CATCloneManager MyManager(GeoFactoryForPasting); // the CATGeoFactory is also a container
MyManager.Add(C1);   
MyManager.Add(C2);
// Copies C1 and C2 and paste them in GeoFactoryForPasting
MyManager.Run();  
// Retrieves the copy of C1  
CATICGMObject* ClonedObject=MyManager.ReadImage(C1);

[Top]

How a CATICGMObject and a CATCloneManager Cooperate

The CATCloneManager globally manages the cloning, but delegates the copy of a single object to each object.

  1. The CATCloneManager asks the object to clone itself through the CATICGMObject::Clone method.
  2. The object to clone asks back the CATCloneManager for the copy of its forward linked objects through the CATCloneManager::ComputeImage method.

Hence, there are two types of methods of a CATCloneManager

[Top]

The CATTransfoManager

This operator is a kind of CATCloneManager, that moves CATGeometry objects, with or without copying them. This part highlights the new properties and behaviors with respect to those inherited from CATCloneManager.

[Top]

Inherited Properties

The global architecture is of course inherited. It includes:

[Top]

New Properties

The rules for the duplication of the forward linked objects in the same container are as follows:

The following figures illustrate the behavior of the CATTransfoManager in different cases:

Fig3: Behavior of the CATTransfoManager when a forward linked object belongs to the selection, according to the CATTransfoManagerType

Clone3.gif (9258 bytes)

In these diagrams, a forward linked object (Surface) belongs to the selection.

If an object that points to Surface is not in the selection (as C1), Surface is duplicated and moved in Surface_d. In replace mode, the other selected objects C2 and C3 point now to this new surface Surface_d.

If all the objects pointing to Surface are selected :

* In replace mode, Surface is moved: the relative position between the curves and Surface remains the same, and C1, C2, C3 are not touched. Note that in some rare cases, the curves will also be moved, because the parameterization of the transformed surface can change from the initial one. This is the case when the surface is defined from a curve or another surface, themselves invariant by the transformation.

* In duplicate mode, all is duplicated. Notice that the duplicated surface only needs to be moved.

Note

Fig4: Behavior of the CATTransfoManager when a forward linked object does not belong to the selection, nor a pointing object

Clone4.gif (9549 bytes)

In these diagrams, a forward linked object Surface does not belong to the selection, nor the pointing curve C1.

In replace mode, if Surface is invariant, there is no need to duplicate it. C2 and C3 are only moved. If Surface is not invariant, it must be duplicated before the transformation

In duplicate mode, if Surface is invariant, there is no need to duplicate it. C1 and C2 are duplicated and moved, pointing to the same Surface. If Surface is not invariant, all is duplicated.

 

Fig5: Behavior of the CATTransfoManager when all the pointing objects are in the selection, but not the forward linked object

Clone5.gif (7357 bytes)

In these diagrams, the forward linked object Surface does not belong to the selection, but all the pointing curves C1 and C2 are selected.

In replace mode, if Surface is invariant, there is no need to duplicate it. C1 and C2 are only moved. If Surface is not invariant, it is moved, and the C1 and C2 are not touched.

In duplicate mode, if Surface is invariant, there is no need to duplicate it. C1 and C2 are duplicated and moved, pointing to the same Surface. If Surface is not invariant, all is duplicated.

The specific methods of a CATTransfoManager are

[Top]


In Short

[Top]


References

[1] The CGM Objects
[2] The Management of Foreign Data
[3] The Curves of CATIA Geometric Modeler
[4] The Surfaces of CATIA Geometric Modeler
[Top]

History

Version: 1 [Mar 2000] Document created
[Top]

Copyright © 2000, Dassault Systèmes. All rights reserved.