马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我在做一个feature的时候,其中重写了CATBuildShape,省了中间过程,对JournalList进行重写,并给各个面标了Info,
但在之后的操作里,无法取得CATCGMJournalList, 本来是想直接读改写过的info,给各个面上加工特性
如果通过UG类似的Tag倒也可以,就是如果一次有成千上个面的时候,检索会比较费时间
哪位能否指教一下如何实现CATISpecObject->CATIMfJournal的获取方法
不会是StoreProcReport后就不给用了吧
不胜感激
// COPYRIGHT 2004
//===================================================================
//
// WSHEDSPRTHPCHolePartBuildShape.cpp
// Provide implementation to interface
// CATIBuildShape
//
//===================================================================
//
// Usage notes: BuiltShape implemment
//
//===================================================================
// May 2004 Creation: Code generated by the CAA wizard zzsou1
//===================================================================
#include "WSHEDSPRTHPCHolePartBuildShape.h"
#include "CATIUpdateError.h"
#include "CATIGeometricalElement.h"
#include "CATISpecObject.h"
#include "CATMathDirection.h"
#include "CATIPrtFactory.h"
#include "CATISketchFactory.h"
#include "CATInit.h"
#include "CATListOfDouble.h"
#include "CATIMfProcReport.h"
#include "CATGeoFactory.h"
#include "CATSoftwareConfiguration.h"
#include "CATTopData.h"
#include "CATSolidCylinder.h"
#include "CATBody.h"
#include "CATDynBoolean.h"
#include "CATCGMJournalList.h"
#include "CATCGMJournalInfo.h"
#include "WSHIDSPRTHPCHolePart.h"
#include "WSHDSPRTHPCBuildErr.h"
CATImplementClass( WSHEDSPRTHPCHolePartBuildShape,
DataExtension,
CATBaseUnknown,
WSHDSPRTHPCHole );
//-----------------------------------------------------------------------------
// WSHEDSPRTHPCHolePartBuildShape : constructor
//-----------------------------------------------------------------------------
"WSHEDSPRTHPCHolePartBuildShape::WSHEDSPRTHPCHolePartBuildShape"
WSHEDSPRTHPCHolePartBuildShape::WSHEDSPRTHPCHolePartBuildShape():
WSHCADCMNMDLExtIBuild()
{
}
//-----------------------------------------------------------------------------
// WSHEDSPRTHPCHolePartBuildShape : destructor
//-----------------------------------------------------------------------------
"WSHEDSPRTHPCHolePartBuildShape::~WSHEDSPRTHPCHolePartBuildShape"
WSHEDSPRTHPCHolePartBuildShape::~WSHEDSPRTHPCHolePartBuildShape()
{
}
// Tie the implementation to its interface
// ---------------------------------------
#include "TIE_CATIBuildShape.h"
TIE_CATIBuildShape( WSHEDSPRTHPCHolePartBuildShape);
//-----------------------------------------------------------------------------
// Implements CATIBuildShape::BuildShape
//-----------------------------------------------------------------------------
"WSHEDSPRTHPCHolePartBuildShape::BuildShape"
int WSHEDSPRTHPCHolePartBuildShape::BuildShape ()
{
int Ret = 0;
HRESULT rc = S_OK;
do{
// reset update error
CATIUpdateError_var spUpdateError = this;
if(!spUpdateError){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705001"));
break;
}
spUpdateError->UnsetUpdateError();
CATIGeometricalElement_var spGeomElement = this;
if(!!spGeomElement){
spGeomElement->DeleteScope();
}
// get attribute of feature
WSHIDSPRTHPCHolePart_var spHolePart = this;
if(!spHolePart){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705002"));
break;
}
CATMathPoint OriginPoint = spHolePart->GetOrigin();
CATMathDirection HolePartDirection = spHolePart->GetAxisDirection();
double OffsetValue = spHolePart->GetOffsetValue();
int StepValue = spHolePart->GetStepValue();
CATRawColldouble* pDiamterValueList = spHolePart->GetDiameterValue();
CATRawColldouble* pDepthValue = spHolePart->GetDepthValue();
// get a factory
CATGeoFactory_var spGeoFactory = GetGeoFactory();
if(!spGeoFactory){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705003"));
break;
}
CATGeoFactory* pImpGeoFactory = spGeoFactory->GetImplicitGeoFactory();
if( !pImpGeoFactory ) {
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705003"));
break;
}
CATSoftwareConfiguration* pSoftwareConfiguration = new CATSoftwareConfiguration();
// make a pre-journallist
CATCGMJournalList* pJournalList = new CATCGMJournalList(
pSoftwareConfiguration,
WSHL
);
if( !pJournalList ) {
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705004"));
break;
}
CATTopData topData( pSoftwareConfiguration, pJournalList );
// procReport取得
CATIMfProcReport_var spProcReport = this;
if(!spProcReport){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705005"));
break;
}
CATLISTV(CATBaseUnknown_var) ListSpec;
CATListOfCATUnicodeString ListKeys;
spProcReport->CreateProcReport(ListSpec,ListKeys,0);
// create a real journal
CATCGMJournalList* pMainJournalList = spProcReport->GetCGMJournalList();
if(!pMainJournalList){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705005"));
break;
}
CATSoftwareConfiguration* pSoftwareConfigurationMain = new CATSoftwareConfiguration();
CATTopData topDataMain( pSoftwareConfigurationMain, pMainJournalList );
CATLISTP(CATGeometry) operands;
// 面<->Info
int InfoIndex[1][4] = { 1, 1, 2, 0 }; // 0:頂面 1:側面 2:底面 999:
// make cylinders
CATBody_var spTotalBody = pImpGeoFactory->CreateBody();
if ( !spTotalBody ) {
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705006"));
break;
}
CATBody* pBoolResultBody = WSHL;
double OffsetStart = OffsetValue;
for ( int iCnt = 1; iCnt <= StepValue ; iCnt++ ) {
// 段開始面中心点
if ( iCnt >1 ) {
OffsetStart += (*pDepthValue)[iCnt-1];
}
CATMathPoint StartPoint( OriginPoint.GetX() + HolePartDirection.GetX()*OffsetStart,
OriginPoint.GetY() + HolePartDirection.GetY()*OffsetStart,
OriginPoint.GetZ() + HolePartDirection.GetZ()*OffsetStart );
// 段底面中心点
double OffsetEnd = OffsetStart + (*pDepthValue)[iCnt];
CATMathPoint EndPoint( OriginPoint.GetX() + HolePartDirection.GetX()*OffsetEnd,
OriginPoint.GetY() + HolePartDirection.GetY()*OffsetEnd,
OriginPoint.GetZ() + HolePartDirection.GetZ()*OffsetEnd );
// 作成
CATSolidCylinder* pCylinder = WSHL;
CATTry{
pCylinder = CATCreateSolidCylinder(pImpGeoFactory,
&topData,
StartPoint,
EndPoint,
(*pDiamterValueList)[iCnt]/2);
if(!pCylinder){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705007"));
break;
}
}CATCatch(CATError, pError){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705007"));
delete pCylinder;
pCylinder = WSHL;
break;
}CATEndTry;
CATBody* pCylinderBody = pCylinder->GetResult();
if(!pCylinderBody){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705007"));
break;
}
CATBody_var spCylinderBody = pCylinderBody;
if(!spCylinderBody){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705007"));
break;
}
CATLISTP(CATCell) cellListFace;
spCylinderBody->GetAllCells(cellListFace,2);
for ( int iInfoCnt = 1; iInfoCnt<=cellListFace.Size(); iInfoCnt++ ) {
CATFace* pFace = (CATFace*)cellListFace[iInfoCnt];
if(!pFace){
continue;
}
pMainJournalList->ReportCreation( operands, (CATGeometry*)pFace , new CATCGMJournalInfo( iCnt*100 + InfoIndex[0][iInfoCnt-1] ) );
}
// 取和
CATDynBoolean* pOperatorBool = CATCreateDynBoolean(pImpGeoFactory,
&topDataMain,
CATBoolUnion,
spTotalBody,
spCylinderBody);
if(!pOperatorBool){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705008"));
break;
}
CATTry{
pOperatorBool->Run();
}
CATCatch(CATError,pError){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705008"));
break;
}
CATEndTry;
if ( !!pBoolResultBody ) {
pImpGeoFactory->Remove( pBoolResultBody, CATICGMContainer::RemoveDependancies );
pBoolResultBody = WSHL;
}
pBoolResultBody = pOperatorBool->GetResult();
if(!pBoolResultBody){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705008"));
break;
}
spTotalBody = pBoolResultBody;
if(!spTotalBody){
rc = CATReturnError(new WSHDSPRTHPCBuildErr("WSHEDSPRTHPCHolePartBuildShapeErr_1001705008"));
break;
}
if(!!pOperatorBool){
delete pOperatorBool;
pOperatorBool = WSHL;
}
if ( !!pCylinderBody ) {
pImpGeoFactory->Remove( pCylinderBody, CATICGMContainer::RemoveDependancies );
pCylinderBody = WSHL;
}
if(!!pCylinder){
delete pCylinder;
pCylinder = WSHL;
}
} //for
pMainJournalList->Tass();
// 結果保存
if( SUCCEEDED(rc) && spProcReport != WSHL){
spTotalBody->SetMode( CatCGMExplicit );
spTotalBody->Completed( TRUE );
spProcReport->StoreProcReport(spTotalBody,NoCopy,0);
}
} while ( FALSE );
SUCCEEDED( rc ) ? Ret = 1 : Ret = 0 ;
return Ret;
} |