Machining |
NC Review |
Cutting Polylines of a Tool PathManipulating a tool path |
Use Case |
AbstractThis article discusses the CAAMfgTPEPolylineSelectionUserCom use case. |
This use case is intended to help you manipulate the tool path structure. This involves the following:
[Top]
CAAMfgTPEPolylineSelectionUserCom is a use case of the CAAToolPathEditorItf.edu framework that illustrates ToolPathEditor framework capabilities.
[Top]
CAAMfgTPEPolylineSelectionUserCom runs with the document CAAMfgToolPath.CATPart shown on Fig.1.
![]() |
[Top]
# Decomment this line to run CAAMfgTPEPolylineSelectionUserCom Sample #CAAMfgTPEM3xAddin CATISmgProgramAddin libCAAMfgTPEAddToolBar #CATM3xAreaModificationAlgoDriver CATIMfgTPECutAreasEditor libCAAMfgTPEAddCmdInCutAreaToolBar #CATM3xAreaModificationAlgoDriver CATIMfgTPECutAreasUserHeader libCAAMfgTPEAddCmdInCutAreaToolBar
Windows | InstallRootDirectory\CAADoc\CAAToolPathEditorItf.edu\CNext\resources\graphic |
Unix | InstallRootDirectory/CAADoc/CAAToolPathEditorItf.edu/CNext/resources/graphic |
Once the part is opened, proceed as follows.
Select a body, then do replay to compute the tool path.
In the PPR tree, an icon appears under the activity of sweeping.
[Top]
Windows | InstallRootDirectory\CAADoc\CAAToolPathEditorItf.edu\CAAMfgTPEAddCmdInCutAreaToolBar.m |
Unix | InstallRootDirectory/CAADoc/CAAToolPathEditorItf.edu/CAAMfgTPEAddCmdInCutAreaToolBar.m |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
There are four logical steps in CAAMfgTPEPolylineSelectionUserCom
We now comment each of those sections by looking at the code.
[Top]
The class that will implement the command is named CAAMfgTPEPolylineSelectionUserCom.
Create the CAAMfgTPEPolylineSelectionUserCom class header file:
class ExportedByCAAMfgTPEAddCmdInCutAreaToolBar CAAMfgTPEPolylineSelectionUserCom : public CATStateCommand { public: DeclareResource (CAAMfgTPEPolylineSelectionUserCom, CATStateCommand) //CAAMfgTPEPolylineSelectionUserCom( CATCommand *iFather, // CATM3xAreaModificationAlgoDriver* AlgoDriver); CAAMfgTPEPolylineSelectionUserCom (void* ipCutAreasEditor); virtual ~CAAMfgTPEPolylineSelectionUserCom (); void BuildGraph(); CATBoolean End(void *Data); CATStatusChangeRC Cancel (CATCommand*, CATNotification*); CATStatusChangeRC Desactivate (CATCommand*, CATNotification*); CATStatusChangeRC Activate (CATCommand*, CATNotification*); void Valuate (int iSwitch); boolean LineSelection(void* Data); private: CATIMfgTPECutAreasEditor* _hCutEditor; CATSelector* _Selector; CAT3DViewer* _Viewer; CATPathElementAgent* _EndAgent; CATDialogAgent* _PointAgent; int _NumPolyline; }; |
The CAAMfgTPEPolylineSelectionUserCom class C++-derives from CATStateCommand. The DeclareResource macro declares that the ressource file is CAAMfgTPEPolylineSelectionUserCom.CATNls. The class has a constructor, a destructor, a LineSelection method which manages the click on the tool path and gives the number of polyline to the tool path editor, several methods to manage the user's interaction and the representation of the tool path, and a copy constructor.
This command will communicate with the tool path editor by the interface CATIMfgTPECutAreasEditor.
[Top]
First you have to create a selector which must work with the representation
of the tool path. This last one can be retrieved by a call to the method GetToolPathRep
of the interface CATIMfgTPECutAreasEditor. A call to the method BeginPolylineToCut
is made to initialize the action.
The first argument of the constructor is used to get the interface CATIMfgTPECutAreasEditor. This is done in the constructor.
CAAMfgTPEPolylineSelectionUserCom::CAAMfgTPEPolylineSelectionUserCom (void* ipCutAreasEditor) : CATStateCommand("TPEPolygonSelection",NULL,CATCommandModeShared), _PointAgent(NULL), _Viewer(NULL), _Selector(NULL), _EndAgent(NULL),_NumPolyline(0) { CATFrmLayout* ptrFrmLayout = CATFrmLayout::GetCurrentLayout(); if ( ptrFrmLayout) { const CATFrmWindow * ptrFrmWindow = ptrFrmLayout->GetCurrentWindow (); if (ptrFrmWindow && ptrFrmWindow->IsAKindOf(CATFrmGraphAnd3DWindow::ClassName()) ) { CATFrmGraphAnd3DWindow* ptr3DWindow = (CATFrmGraphAnd3DWindow*)ptrFrmWindow; CATViewer * viewer = ptr3DWindow->GetGraphicViewer(); if( viewer && viewer->IsAKindOf(CAT3DViewer::ClassName()) ) _Viewer = (CAT3DViewer*)viewer; } } _hCutEditor = (CATIMfgTPECutAreasEditor*)ipCutAreasEditor; // Erase of the last preview if (NULL_var != _hCutEditor) { _hCutEditor->ClearAll(); _hCutEditor->BeginPolylineToCut(); } // Create the selector CATRep* Rep = NULL; if (NULL != _hCutEditor) Rep = _hCutEditor->GetToolPathRep(); _Selector = new CATSelector (this,"ToolPathSelector", Rep); } |
Now the method BuildGraph is implemented. It gets the click on the tool path and the double-click to terminate the command.
void CAAMfgTPEPolylineSelectionUserCom::BuildGraph() { _PointAgent = new CATDialogAgent("Point"); if (NULL != _Selector) { _PointAgent->AcceptOnNotify(_Selector, _Selector->GetCATActivate()); _PointAgent->SetBehavior(CATDlgEngWithPrevaluation|CATDlgEngWithUndo|CATDlgEngRepeat|CATDlgEngAcceptOnPrevaluate); // Dialog States CATDialogState* InitState = GetInitialState("UserPolylineSelection"); if (NULL != InitState) { InitState->AddDialogAgent(_PointAgent); _EndAgent = new CATPathElementAgent("End"); if (NULL != _EndAgent) { _EndAgent->AcceptOnNotify(NULL, CATEdit::ClassName()); InitState->AddDialogAgent(_EndAgent); AddTransition( InitState, InitState, IsOutputSetCondition(_PointAgent), Action((ActionMethod)& CAAMfgTPEPolylineSelectionUserCom::LineSelection)); AddTransition( InitState, NULL, IsOutputSetCondition(_EndAgent), Action((ActionMethod)& CAAMfgTPEPolylineSelectionUserCom::End)); SetRepeatMode(ON); } } } } |
[Top]
This is done by the method LineSelection. Two calls to the method LoadPolylineToCut of the interface CATIMfgTPECutAreasEditor are made to give the polylines to the tool path editor.
boolean CAAMfgTPEPolylineSelectionUserCom::LineSelection(void* Data) { // Simulate a selection of polyline. CATListOfInt* Liste = new CATListOfInt(); CATIMfgToolPath_var toolPath; CATIMfgCompoundTraject_var compoundTraject; if ( SUCCEEDED(_hCutEditor->GetToolPath(toolPath) ) ) { compoundTraject = toolPath; if ( !! compoundTraject ) { CATListValCATBaseUnknown_var ListofElement; boolean result = compoundTraject->GetAllElementaryTrajects(ListofElement); int NbElement = ListofElement.Size(); if ( NbElement == 1) { CATIMfgTPMultipleMotion_var spMultipleMotion (ListofElement[1]); if (NULL_var != spMultipleMotion) { int number; spMultipleMotion->GetNumberOfSubTrajects(number); _NumPolyline++; if (_NumPolyline < number) Liste->Append(_NumPolyline); _NumPolyline++; if (_NumPolyline < number) Liste->Append(_NumPolyline); } } } } _hCutEditor->LoadPolylineToCut(Liste); /////////////////////////////////////// Liste->RemoveAll(); if ( !! compoundTraject ) { CATListValCATBaseUnknown_var ListofElement; boolean result = compoundTraject->GetAllElementaryTrajects(ListofElement); int NbElement = ListofElement.Size(); if ( NbElement == 1) { CATIMfgTPMultipleMotion_var spMultipleMotion (ListofElement[1]); if (NULL_var != spMultipleMotion) { int number; spMultipleMotion->GetNumberOfSubTrajects(number); _NumPolyline++; if (_NumPolyline < number) Liste->Append(_NumPolyline); } } } _hCutEditor->LoadPolylineToCut(Liste); delete Liste; if (NULL != _PointAgent) _PointAgent->InitializeAcquisition(); return CATTrue; } |
The next step is to end the action.
This is done by the method End
. A call to the method EndPolylineToCut
of the interface CATIMfgTPECutAreasEditor is made.
CATBoolean CAAMfgTPEPolylineSelectionUserCom::End(void *data) { if ( _Viewer ) { _Viewer->SetCursor(CATDialog::NorthWestArrow); } // End of the selection of polyline CAT3DRep* TPRep = NULL; if (NULL_var != _hCutEditor) { _hCutEditor->EndPolylineToCut(); } RequestDelayedDestruction(); return CATTrue; } |
Then the tool path editor manages this part of the tool path with all the actions of the cut area tool bar.
[Top]
This article provides an example on how to cut some polylines of a tool path by adding a new command in the cut area tool bar.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[2] | Use case CAAMfgTPECutAreasUserHeader |
[Top] |
Version: 1 [March 2002] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.