PPR Hub |
Product Modeler |
Enabling the Visualization of New Features in a Product DocumentIntegrating new features in the visualization process |
Use Case | ||
CAAPstIntegrateNewFeatures > CAAPstINFBuildCatalog > CAAPstINFCreateDocument > CAAPstINFNavigate > CAAPstINFInitCont > CAAPstINFVisu > CAAPstINFGraphicalProperties > CAAPstINFEdit > CAAPstINFCCP > CAAPstINFDelete > CAAPstINFUpdate |
AbstractThis article discusses the CAAPstINFVisu use case. This use case explains how to allow new features created "from scratch" to be visualized in a Product document. |
This use case is intended to illustrate how new features created "from scratch" in an applicative container of a Product document can be integrated in the visualization process of a Product document. The native CATIA visualization process takes into account the different containers and features that are native to a particular document type. However, it has no knowledge of features created in user-defined applicative containers. The purpose of this use case is to show how these types of features can nevertheless be visualized in a viewer of a Product document.
[Top]
The CAAPstINFVisu is a use case of the CAAProductStructure.edu framework that illustrates the integration of ObjectSpecsModeler, Visualization and ProductStructure capabilities in the scope of a Product document.
[Top]
This use case illustrates the integration in the visualization process of new features created in an applicative container within a Product document. Following are the contents of the applicative container we will be working with in the CAAPstINFDocument.CATProduct document supplied with this use case.
Fig. 1: Contents of the CAAPstINFDocument.CATProduct document.![]() |
As you can see, initially, we are basically working with 5 features: two "CAAPstINFRoot" features, two "CAAPstINFPoint" features and one "CAAPstINFLine" feature. Only the "CAAPstINFPoint" and "CAAPstINFLine" features need to have a geometric visualization. However, because these features are created in an applicative container, the native visualization process would normally not take into account their visualization procedures. What must be done in order for the visualization process to take them into account, is to create a provider implementation that will be called during the visualization process and that will return a list of the features whose visualization must be constructed.
In our example, the visualization provider algorithm returns a list containing the two "CAAPstINFPoint" features and the "CAAPstINFLine" feature. Then, the visualization process can call the CATI3DGeoVisu implementations of each of these features in order to be able to visually display their geometry in the viewer.
This use case will explain how to program the visualization provider (CATIVisuProvider implementation) as well as the CATI3DGeoVisu implementation of the "CAAPstINFPoint" and "CAAPstINFLine" features.
What is very important to remember is that provider implementations are runtime mechanisms. In order to activate them at runtime, it is necessary to declare them to the document during its initiation. Because our features are all created in the same applicative container, a natural place for declaring our providers would be during the initialization of the applicative container. This means implementing the CATInit::Init method for our applicative container. This code is described in the "Creating New Features 'From Scratch' in a Product Document" article [2] related to this use case which illustrates the initial construction of the Product document.
[Top]
To launch the CAAPstINFVisu use case, you will need to set up the build time
environment, then compile CAAPstINFModeler.m shared library along with its
prerequisites [3]. Then, you can execute use case
simply by launching a new CATIA session and loading (File + Open
)
the CAAPstINFDocument.CATProduct document that has been supplied with
this use case in the CAAProductStructure.edu/CNext/resources/graphic
file directory. The Product document will be displayed and you will be
able to visualize the geometry of the new features in the current viewer.
[Top]
The CAAPstINFVisu use case is made of a several modules of the CAAProductStructure.edu framework:
Windows | InstallRootDirectory\CAAProductStructure.edu\ |
Unix | InstallRootDirectory/CAAProductStructure.edu/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
There are two logical steps to CAAPstINFVisu:
We will now comment each of these sections by looking at the code.
[Top]
Coding a Visualization Provider Implementation of CATIVisuProvider
HRESULT CAAPstINFVisuProviderRoot::GetChildren(CATBaseUnknown *pObj, CATLISTP(CATBaseUnknown) **pListChildren) { cout << "***** CAAPstINFVisuProviderRoot::GetChildren" << endl; HRESULT rc = E_FAIL; //------------------------------------------------------ // Verify that the caller is actually the Product root. //------------------------------------------------------ // Retrieve a CATIProduct handle on the caller object CATIProduct *piProductOnObj = NULL; rc = pObj -> QueryInterface (IID_CATIProduct, (void**) &piProductOnObj); if (SUCCEEDED(rc)) { // Retrieve the father of the product: if it has none, this must be the root. CATIProduct *piFatherProd = piProductOnObj -> GetFatherProduct(); piProductOnObj -> Release(); piProductOnObj = NULL; if (piFatherProd != NULL) { cout << "The caller is not the aggregating root product." << endl << flush; piFatherProd -> Release(); piFatherProd = NULL; return S_OK; } else cout << "The caller is the aggregating root product: continue" << endl; //--------------------------------------------------------------------------- // Retrieve the applicative container containing the features to be returned //--------------------------------------------------------------------------- // Retrieve a pointer to the current document CATILinkableObject *piLinkableOnObj = NULL; rc = pObj -> QueryInterface (IID_CATILinkableObject, (void**) &piLinkableOnObj); if (FAILED(rc)) return E_FAIL; CATDocument* pDoc = piLinkableOnObj->GetDocument(); piLinkableOnObj -> Release(); piLinkableOnObj = NULL; // Retrieve a pointer to the applicative container CATUnicodeString appliContIdentifier("PstINFContainer"); CATBaseUnknown *pApplicativeContainer = NULL; rc = ::CATGetApplicativeContainer (&pApplicativeContainer, pDoc, IID_CATIContainer, appliContIdentifier); if (SUCCEEDED(rc)) cout << "Applicative container retrieved OK" << endl << flush; else { cout << "ERROR in retrieving applicative container" << endl << flush; return E_FAIL; } // Retrieve a pointer to CATIClientContainer in order to list the members // of the applicative container. CATIClientContainer *piClientOnAppliCont = NULL; rc = pApplicativeContainer -> QueryInterface(IID_CATIClientContainer, (void**) &piClientOnAppliCont); pApplicativeContainer -> Release(); pApplicativeContainer = NULL; if (NULL == piClientOnAppliCont) { cout << "ERROR in retrieving container pointer" << endl << flush; return E_FAIL; } else cout << "CATIClientContainer pointer retrieved OK" << endl << flush; //------------------------------------------------------------ // Retrieve the list of features in the applicative container //------------------------------------------------------------ CATUnicodeString clientId("CAAPstINFClientId"); CATListPtrCATBaseUnknown *pMemberList = NULL; rc = piClientOnAppliCont -> ListMembers(IID_CATISpecObject, clientId, &pMemberList); piClientOnAppliCont -> Release(); piClientOnAppliCont = NULL; if (SUCCEEDED(rc)) cout << "Member list retrieved OK" << endl << flush; else { cout << "ERROR in retrieving member list" << endl; return E_FAIL; } cout << "Number of members in applicative container: " << pMemberList->Size() << endl << flush; //---------------------------------------------------------------------------- // Scan through the list in order to retrieve the "CAAPstINFRoot" feature and // return the features it aggregates through the "ListOfComponents" attribute. //---------------------------------------------------------------------------- CATUnicodeString rootType(""); CATISpecObject *piSpecMember = NULL; for(int i=1;i<=pMemberList->Size();i++) { piSpecMember = (CATISpecObject *) (*pMemberList)[i]; rootType = piSpecMember -> GetType(); if (rootType == "CAAPstINFRoot") { CATISpecAttrAccess *piAttrAccessOnRoot = NULL; rc = piSpecMember -> QueryInterface(IID_CATISpecAttrAccess, (void**) &piAttrAccessOnRoot); if (FAILED(rc)) { delete pMemberList; pMemberList = NULL; return rc; } CATISpecAttrKey *piListComponentKey = NULL; piListComponentKey = piAttrAccessOnRoot -> GetAttrKey ("ListOfComponents"); if (!piListComponentKey) { delete pMemberList; pMemberList = NULL; return rc; } CATISpecObject *piComponent = NULL; piAttrAccessOnRoot -> Beginning(piListComponentKey); while (piAttrAccessOnRoot -> Next(piListComponentKey)) { piComponent = piAttrAccessOnRoot -> GetSpecObject(piListComponentKey); if (NULL == piComponent) { cout << "Error in retrieving component" << endl; piAttrAccessOnRoot -> Release(); piAttrAccessOnRoot = NULL; piListComponentKey -> Release(); piListComponentKey = NULL; delete pMemberList; pMemberList = NULL; return E_FAIL; } (*pListChildren) -> Append(piComponent); piComponent = NULL; } piSpecMember = NULL; piAttrAccessOnRoot -> Release(); piAttrAccessOnRoot = NULL; piListComponentKey -> Release(); piListComponentKey = NULL; } } delete pMemberList; pMemberList = NULL; } return S_OK; } |
[Top]
Implementing CATI3DGeoVisu to Visualize New Features
[Top]
The CAAPstINFVisu use case has shown you how to integrate new features created "from scratch" in an applicative container in the visualization process of a Product document.
[Top]
[1] | Feature Modeler Overview |
[2] | The Product Structure Model |
[Top] |
Version: 1 [May 2002] | Document created |
[Top] |
Copyright © 2002, Dassault Systèmes. All rights reserved.