Solution

Modeler

Managing Axis Systems

Using CATIMf3DAxisSystemManager
Use Case

Abstract

This article shows how to use the CATIMf3DAxisSystemManager interface.


What You Will Learn With This Use Case

This use case is intended to show you how to use the CATIMf3DAxisSystemManager interface to:

[Top]

The CAAMmrAxisSystemManagement Use Case

CAAMmrAxisSystemManagement is a use case of the CAAMechanicalModeler.edu framework that illustrates MechanicalModeler framework capabilities.

[Top]

What Does CAAMmrAxisSystemManagement Do

CAAMmrAxisSystemManagement lists all the axis systems of a Part document, sets as current an axis system, and transforms the (0,0,0) point and the (0,0,1) vector in this current axis system.

If you use the CAAAxisSystemCreation_Save Part document created by the CAAMmrAxisSystemCreation use case [1] :

Fig.1: The CAAAxisSystemCreation_Save Part document

The list of axis systems is the following: (*)

You can see in the Fig-1 that there is no axis system with the icon, so there is no axis system as current. The AS_Standard axis system is set as standard: (*)

The origin of the absolute axis system and the z vector are translated in the AS_Standard axis system:  (*)

The AS_Standard characteristics are the following:

*) It is an extract of the CAAMmrAxisSystemManagement output traces. 

[Top]

How to Launch CAAMmrAxisSystemManagement

To launch CAAMmrAxisSystemManagement , you will need to set up the build time environment, then compile CAAMmrAxisSystemManagement along with its prerequisites, set up the run time environment, and then execute the use case [2]. To launch the use case execute the command:

mkrun -c CAAMmrAxisSystemManagement Filename CurrentAS [OutputPath]

where

[Top]

Where to Find the CAAMmrAxisSystemManagement Code

The CAAMmrAxisSystemManagement use case is made of one module, CAAMmrAxisSystemManagement.m,  found in the the CAAMechanicalModeler.edu framework and containing a single source program, CAAMmrTestManagement.cpp:

Windows InstallRootDirectory\CAAMechanicalModeler.edu\CAAMmrAxisSystemManagement.m\
Unix InstallRootDirectory/CAAMechanicalModeler.edu/CAAMmrAxisSystemManagement.m/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

[Top]

Step-by-Step

There are eight logical steps in CAAMmrAxisSystemManagement:

  1. Prolog
  2. Retrieves the CATIMf3DAxisSystemManager Interface Pointer
  3. Displays the Count of Axis Systems
  4. Finds the Current Axis System
  5. Retrieves the Input Axis System in the Axis System List
  6. Sets the New Current Axis System
  7. Transforms the (0,0,0) Point and the (0,0,1) Vector in the Current Axis System 
  8. Epilog

[Top]

Prolog

CAAMmrAxisSystemManagement begins by creating a session, and opening the input Part document. Next it retrieves the root container of this Part as a pointer to CATIPrtContainer, pIPrtContOnDocument. This is the usual sequence for loading a Part document [3].

[Top]

Retrieves the CATIMf3DAxisSystemManager Interface Pointer

The CATIMf3DAxisSystemManager interface is implemented by the root container, pIPrtContOnDocument, which is also the specification container of the Part document [4].

...
  CATIMf3DAxisSystemManager * pIMf3DAxisSystemManagerOnFeatCont = NULL ;
  rc = pIPrtContOnDocument->QueryInterface(IID_CATIMf3DAxisSystemManager,
                                      (void **) & pIMf3DAxisSystemManagerOnFeatCont);
...

[Top]

Displays the Count of Axis Systems

pIMf3DAxisSystemManagerOnFeatCont is the CATIMf3DAxisSystemManager interface pointer. The GetAxisSystems method retrieves the list of axis systems in the Part document.

...
  CATLISTV(CATIMf3DAxisSystem_var) ListAxisSystem ;
  rc = pIMf3DAxisSystemManagerOnFeatCont->GetAxisSystems(ListAxisSystem);
  ...

  int nbAS = ListAxisSystem.Size();
  cout <<"   There are " << nbAS << " axis system(s) in the document" << endl;
  for ( int i= 1 ; i <= nbAS  ; i++)
  {
     CATIMf3DAxisSystem_var spMf3DAxisSystemOnAS= ListAxisSystem[i] ;
     if ( NULL_var != spMf3DAxisSystemOnAS)
     {
        CATIAlias_var spAliasOnCurrentAS = spMf3DAxisSystemOnAS;
        if ( NULL_var != spAliasOnCurrentAS )
        {
            cout<<"      "<< spAliasOnCurrentAS->GetAlias().ConvertToChar() << endl;
        }
     }
  }
...

[Top]

Finds the Current Axis System

The GetCurrentAxisSystem method retrieves the current axis system. If the returned value is NULL_var, no axis system is current.

...
  CATIMf3DAxisSystem_var spMf3DAxisSystemOnCurrentAS ;
  rc=pIMf3DAxisSystemManagerOnFeatCont->GetCurrentAxisSystem(spMf3DAxisSystemOnCurrentAS);
...

[Top]

Retrieves the Input Axis System in the Axis System List

The second argument, iArgv[2], of the use case is the name of an axis system to set as current. If this name is "AbsoluteAS", no axis system should be current. The goal of this section is to find this axis system in the list of axis systems retrieved in the "Displays the Count of Axis Systems" section (ListAxisSystem).

...
  CATUnicodeString NewCurrentAxisName = iArgv[2] ;
  CATUnicodeString AbsoluteAS = "AbsoluteAS" ;
  CATBoolean Found = FALSE ;

  if ( (AbsoluteAS != NewCurrentAxisName) && (OldCurrentAxisName != NewCurrentAxisName) )
  {
      int i = 1 ;
      while ( (FALSE == Found) && ( i<= nbAS ))
      {
          CATIMf3DAxisSystem_var spMf3DAxisSystem = ListAxisSystem[i];
          if ( NULL_var != spMf3DAxisSystem )
          {
             CATIAlias_var spAliasOnCurrentAS = spMf3DAxisSystem ;
             if ( NULL_var != spAliasOnCurrentAS )
             {
                if ( NewCurrentAxisName == spAliasOnCurrentAS->GetAlias() )
                {
                    Found = TRUE ;
                    spMf3DAxisSystemOnCurrentAS = spMf3DAxisSystem;
                }
             }
          }
          i++ ;
      }
      if ( FALSE == Found)
      {
         cout << "   The  " << NewCurrentAxisName <<" has not been found" << endl;
         NewCurrentAxisName = OldCurrentAxisName ;
      }
  }
...

If the input axis system has been found ( Found is equal to TRUE), spMf3DAxisSystemOnCurrentAS, a CATIMf3DAxisSystem interface pointer declared in the "Finds the Current Axis System" section, contains the pointer on this axis system. OldCurrentAxisName is the name of the axis system found in the "Finds the Current Axis System" section. If there is no current axis system, the name is AbsoluteAS. 

[Top]

Sets the Input Axis System as Current

If the input axis system is "AbsoluteAS ", no axis system should be current, the SetCurrentAxisSystem method argument is NULL_var. But, if the input axis system has been found, the SetCurrentAxisSystem method argument is spMf3DAxisSystemOnCurrentAS the CATIMf3DAxisSystem interface pointer on the input axis system.

...
  if ( AbsoluteAS == NewCurrentAxisName)
  {
     rc = pIMf3DAxisSystemManagerOnFeatCont->SetCurrentAxisSystem(NULL_var);
     ...
  }else if ( TRUE == Found )
  {
     rc = pIMf3DAxisSystemManagerOnFeatCont->SetCurrentAxisSystem(spMf3DAxisSystemOnCurrentAS);
     ...
  }
...

[Top]

Transforms the (0,0,0) Point and the (0,0,1) Vector in the Current Axis System 

...
  if ( AbsoluteAS != NewCurrentAxisName)
  {
     CATMathPoint PointToConvert (.0,.0,.0) ;
     CATMathPoint ConvertedPoint;
     
     rc = pIMf3DAxisSystemManagerOnFeatCont->ConvertPointCoordinates(TRUE,
                                                     PointToConvert,ConvertedPoint);
     ...
     
     CATMathVector VectorToConvert (.0,.0,1.0) ;
     CATMathVector ConvertedVector;
     rc = pIMf3DAxisSystemManagerOnFeatCont->ConvertVectorCoordinates(TRUE,
                                                     VectorToConvert,ConvertedVector);                                
...

The first argument of the ConvertPointCoordinates and ConvertVectorCoordinates methods specifies the coordinates system of conversion: TRUE : the current axis system , FALSE the absolute axis system.

[Top]

Epilog

The last actions of the use case are the following: save as the Part document, close it and delete the session. It is also described in the Creating a Load Document use case [3].

[Top]


In Short

This use case explains how to use the CATIMf3DAxisSystemManager interface.

[Top]


References

[1] Creating Axis Systems
[2] Building and Launching a CAA V5 Use Case
[3] Loading a Document
[4] The Structure of the Part Document
[Top]

History

Version: 1 [Apr 2003] Document created
[Top]

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