3D PLM Enterprise Architecture

3D Visualization

Constructing Graphic Representations in Batch Mode

How to use the CATVisManager in batch mode
Use Case

Abstract

This article shows how to construct graphic representations in batch mode. 


What You Will Learn With This Use Case

This use case is intended to show you how to use the CATVisManager to construct the graphic representations (rep) of a model. 

[Top]

The CAAGviVisuBatch Use Case

CAAGviVisuBatch is a use case of the CAAGeometryVisualization.edu framework that illustrates Visualization and VisualizationBase framework capabilities.

[Top]

What Does CAAGviVisuBatch Do

CAAGviVisuBatch constructs the graphic representations associated with the MechanicalPart (Part1) of the following Model:

Fig.1 The CAAVisuBatch Part Document

[Top]

How to Launch CAAGviVisuBatch

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

mkrun -c CAAGviVisuBatch InputPart 

where InputPart is the complete path of a Part document. You can use the following Part document:

[Top]

Where to Find the CAAGviVisuBatch Code

The CAAGviVisuBatch use case is made of a single file, CAAGviVisuBatch.cpp, located in the CAAGviVisuBatch.m module of the CAAGeometryVisualization.edu framework:

Windows InstallRootDirectory\CAAGeometryVisualization.edu\CAAGviVisuBatch.m\
Unix InstallRootDirectory/CAAGeometryVisualization.edu/CAAGviVisuBatch.m/

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

[Top]

Step-by-Step

There are seven logical steps in CAAGviVisuBatch:

  1. Prolog
  2. Creates a Path with the MechanicalPart feature of the Part Document
  3. Retrieves the unique CATVisManager Instance 
  4. Attaches the Root Model to the CATVisManager
  5. Retrieves the Graphic Representation of the MechanicalPart feature
  6. Detaches the Root Model from the CATVisManager
  7. Epilog

[Top]

Prolog

CAAGviVisuBatch begins by creating a session, and opening a Part document. Next it retrieves the root container of this Part as a pointer to CATIPrtContainer, pISpecContainer. This is the usual sequence for loading a Part document.

Thanks to  the GetPart method on the root container we retrieve the Mechanical Part. This part is handled by the smart pointer spSpecObjectOnMechanicalPart.

Creates a Path with the MechanicalPart feature of the Part Document

...
 CATPathElement * pRootObjectPath = new CATPathElement(spSpecObjectOnMechanicalPart);       
...

In this use case, the CATPathElement is built with the root feature of the Part Document. This feature is the MechanicalPart feature, those called Part1 in the specification tree. Refer to the Mechanical Modeler articles. But anyhow, you can create this path with any feature of the model. 

Retrieves the unique CATVisManager Instance 

...
 CATVisManager* pVisManager = CATVisManager::GetVisManager();   
...

There is only one instance of the CATVisManager class in a session. The GetVisManager static method enables you to retrieve it.

Attaches the Root Model to  the CATVisManager

...
    list<IID> ListIVisu3d;
    IID * pIIDInf = new IID(IID_CATI3DGeoVisu) ;
    ListIVisu3d.fastadd(pIIDInf);

    CAT3DViewpoint * pVP = new CAT3DViewpoint();
    
    rc = pVisManager->AttachTo ( pRootObjectPath, pVP, ListIVisu3d);
...

On the CATVisManager you attach to the CATVisManager:

The AttachTo method constructs the graphic representations. 

Retrieves the Graphic Representation of the MechanicalPart feature

...
    CATI3DGeoVisu * pIVisuOnRoot =NULL ;    
    rc = spSpecObjectOnMechanicalPart->QueryInterface(IID_CATI3DGeoVisu,
                                                          (void **) & pIVisuOnRoot);
    ...
       CATRep * pRep = pIVisuOnRoot->GiveRep();
       if ( NULL != pRep )
       {
          CAT3DRep * p3DRep = (CAT3DRep *) pRep;

          CAT3DBoundingSphere pBe = p3DRep->GetBoundingElement();
          ...

...

After the AttachTo method, it is possible to retrieve the graphic representations (rep) of an element thanks to the GiveRep method of the CATI3DGeoVisu interface. In this use case, the rep of the MechanicalPart feature (the root) is asked. 

Detaches the Root Model from the CATVisManager

...
 rc = pVisManager->DetachFrom(pVP,0) ;
 pVP->Release();
 pVP = NULL ;
...

When the graphic representations are useless, you should detach the root model from the CATVisManager. With the DetachFrom method with only the viewpoint, all the root models and the list of interfaces attached with this viewpoint will be detached too. (The same root model can be attached with different viewpoints and with different interfaces)

[Top]

Epilog

The last part of the CAAGviVisuBatchuse case shows how to removes the Part document from the session and delete the session. This is also described in the "Loading a Document" use case (see Data Access entry in the CAA Encyclopedia home page)

[Top]


In Short

This use case explains how to use the CATVisManager to create the graphic representations of model in a batch.

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[Top]

History

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

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