iCAx开思工具箱

标题: 【求助】CAA草图的旋转用什么函数 [打印本页]

作者: liketulip    时间: 2004-9-24 19:22
标题: 【求助】CAA草图的旋转用什么函数
或者直接画球或者圆柱
CreateSphere如何使用
作者: acoka    时间: 2004-9-24 22:28
草图旋转改它的HV轴方向就可以
作者: liketulip    时间: 2004-9-25 19:49
是我没说明白 
我的意思是
把草图的二维图形旋转成3维模型
另外请教一下如何得到当前窗口中模型及其参数
作者: acoka    时间: 2004-9-27 09:14
liketulip wrote:
或者直接画球或者圆柱  
  CreateSphere如何使用

  
CreateSphere是做圆球表面的,是GSM
  
CATSolidSphere,CATSolidCylinder 是做球体的
作者: acoka    时间: 2004-9-27 09:25
acoka wrote:
   
  
  CreateSphere是做圆球表面的,是GSM  
  
  CATSolidSphere,CATSolidCylinder 是做球体的

  
旋转sketch到实体用 Revol( 接口CATIRevol, CATIShaft,CATUGroove)
比如可以CreateRevol做个旋转体
作者: liketulip    时间: 2004-9-27 14:03
CATSolidSphere * CATCreateSolidSphere( CATGeoFactory*  iFactory,  
  CATTopData*  iData,  
  const CATMathPoint&  iCenter,  
  double  iRadius)   
里面的CATTopData如何定义和设置呢?
参考帮助我是这么写的  
CATGeoFactory* piGeomFactory = ::CATCreateCGMContainer() ;
  CATMathPoint p1(0,0,0);  // the sphere center
  CATSoftwareConfiguration * pConfig = new CATSoftwareConfiguration();
  CATTopData topdata(pConfig,NULL);
  CATSolidSphere * pSphereOpe = ::CATCreateSolidSphere(piGeomFactory,  
     topdata,
     p1,
     100.0);  
  pSphereOpe -> Run();
  CATBody * pBodySphere = pSphereOpe -> GetResult();
不过编译出现了以下的LINK错误
TorusCmd.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall CATTopData::~CATTopData(void)" (__imp_??1CATTopData@@UAE@XZ)
TorusCmd.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class CATSolidSphere * __cdecl CATCreateSolidSphere(class CATGeoFactory *,class CATTopData *,class CATMathPoint const &,double)" (__imp_?CATCreateSolidSphere@@YAPAVCATSolidSphere@@PAVCATGeoFactory@@PAVCATTopData@@ABVCATMathPoint@@N@Z)
TorusCmd.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall CATTopData::CATTopData(class CATSoftwareConfiguration *,class CATCGMJournalList *)" (__imp_??0CATTopData@@QAE@PAVCATSoftwareConfiguration@@PAVCATCGMJournalList@@@Z)
TorusCmd.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class CATGeoFactory * __cdecl CATCreateCGMContainer(double)" (__imp_?CATCreateCGMContainer@@YAPAVCATGeoFactory@@N@Z)
E:\UsercaseWorkspace\hcl\WBK\.\intel_a\code\bin\WorkBench.dll : fatal error LNK1120: 4 unresolved externals
作者: acoka    时间: 2004-9-27 14:54
先把linkerror解决了再说
作者: liketulip    时间: 2004-9-27 15:23
我想知道linkerror指的是什么
因为就是因为这段代码产生的linkerror
应该是CATTopData引起的吧
作者: acoka    时间: 2004-9-27 15:49
identityFile里加NewTopologicalObjects
  
iMakeFile里加CATTopologicalObjects
作者: liketulip    时间: 2004-9-27 16:15
iMakeFile里已经include了
identityFile里没有加加NewTopologicalObjects  
加了之后还有两个错误
还是和CATTopData有关
TorusCmd.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class CATSolidSphere * __cdecl CATCreateSolidSphere(class CATGeoFactory *,class CATTopData *,class CATMathPoint const &,double)" (__imp_?CATCreateSolidSphere@@YAPAVCATSolidSphere@@PAVCATGeoFactory@@PAVCATTopData@@ABVCATMathPoint@@N@Z)
TorusCmd.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class CATGeoFactory * __cdecl CATCreateCGMContainer(double)" (__imp_?CATCreateCGMContainer@@YAPAVCATGeoFactory@@N@Z)
作者: liketulip    时间: 2004-9-27 16:15
AddPrereqComponent("ObjectModelerBase",Public);
AddPrereqComponent("System",Protected);
AddPrereqComponent("MechanicalModelerUI",Protected);
AddPrereqComponent("ApplicationFrame",Protected);
AddPrereqComponent("Dialog",Protected);
// END WIZARD EDITION ZONE
AddPrereqComponent("MecModInterfaces",Protected);
AddPrereqComponent("artInterfaces",Protected);
AddPrereqComponent("InteractiveInterfaces",Protected);
AddPrereqComponent("SketcherInterfaces",Protected);
AddPrereqComponent("ObjectSpecsModeler",Protected);
AddPrereqComponent("Dialog",Protected);
AddPrereqComponent("Mathematics",Protected);
AddPrereqComponent("NewTopologicalObjects",Protected);
作者: liketulip    时间: 2004-9-27 16:16
LINK_WITH = $(WIZARD_LINK_MODULES)  \
               CATMecModInterfaces  \
         CATApplicationFrame  \
         CATObjectModelerBase \         
         CATInteractiveInterfaces \
        CATSketcherInterfaces \
            CATPartInterfaces \
                     CATMathematics \
        CATObjectSpecsModeler \
        CATGeometricObjects  \
        CATMathStream        \
        CATTopologicalObjects
作者: acoka    时间: 2004-9-27 16:22

  
AddPrereqComponent("TopologicalOperators",Protected);
AddPrereqComponent("GeometricObjects",Protected);
  
CATTopologicalOperators  
作者: liketulip    时间: 2004-9-27 16:23
还剩一个
CATMathPoint在identityFile应该包括什么
没找到
作者: acoka    时间: 2004-9-27 16:24
AddPrereqComponent("Mathematics",Protected);
作者: liketulip    时间: 2004-9-27 16:37
AddPrereqComponent("ObjectModelerBase",Public);
AddPrereqComponent("System",Protected);
AddPrereqComponent("MechanicalModelerUI",Protected);
AddPrereqComponent("ApplicationFrame",Protected);
AddPrereqComponent("Dialog",Protected);
// END WIZARD EDITION ZONE
AddPrereqComponent("MecModInterfaces",Protected);
AddPrereqComponent("PartInterfaces",Protected);
AddPrereqComponent("InteractiveInterfaces",Protected);
AddPrereqComponent("SketcherInterfaces",Protected);
AddPrereqComponent("ObjectSpecsModeler",Protected);
AddPrereqComponent("Dialog",Protected);
AddPrereqComponent("Mathematics",Protected);
AddPrereqComponent("TopologicalOperators",Protected);
AddPrereqComponent("GeometricObjects",Protected);
==============================
LINK_WITH = $(WIZARD_LINK_MODULES)  \
     CATMecModInterfaces  \
    CATApplicationFrame  \
   CATObjectModelerBase \  
    CATInteractiveInterfaces \
  CATSketcherInterfaces \
  CATPartInterfaces \
  CATMathematics \
  CATObjectSpecsModeler \
  CATGeometricObjects  \
  CATMathStream        \
  CATTopologicalObjects  
==========================
orusCmd.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall CATTopData::~CATTopData(void)" (__imp_??1CATTopData@@UAE@XZ)
TorusCmd.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class CATSolidSphere * __cdecl CATCreateSolidSphere(class CATGeoFactory *,class CATTopData *,class CATMathPoint const &,double)" (__imp_?CATCreateSolidSphere@@YAPAVCATSolidSphere@@PAVCATGeoFactory@@PAVCATTopData@@ABVCATMathPoint@@N@Z)
TorusCmd.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall CATTopData::CATTopData(class CATSoftwareConfiguration *,class CATCGMJournalList *)" (__imp_??0CATTopData@@QAE@PAVCATSoftwareConfiguration@@PAVCATCGMJournalList@@@Z)
作者: acoka    时间: 2004-9-27 16:48
你把程序的一部分/* */掉
然后逐个分析
作者: liketulip    时间: 2004-9-27 16:53

只剩一个错误了
AddPrereqComponent("ObjectModelerBase",Public);
AddPrereqComponent("System",Protected);
AddPrereqComponent("MechanicalModelerUI",Protected);
AddPrereqComponent("ApplicationFrame",Protected);
AddPrereqComponent("Dialog",Protected);
// END WIZARD EDITION ZONE
AddPrereqComponent("MecModInterfaces",Protected);
AddPrereqComponent("artInterfaces",Protected);
AddPrereqComponent("InteractiveInterfaces",Protected);
AddPrereqComponent("SketcherInterfaces",Protected);
AddPrereqComponent("ObjectSpecsModeler",Protected);
AddPrereqComponent("Dialog",Protected);
AddPrereqComponent("Mathematics",Protected);
AddPrereqComponent("NewTopologicalObjects",Protected);
AddPrereqComponent("GeometricObjects",Protected);
============================
LINK_WITH = $(WIZARD_LINK_MODULES)  \
               CATMecModInterfaces  \
         CATApplicationFrame  \
         CATObjectModelerBase \         
         CATInteractiveInterfaces \
        CATSketcherInterfaces \
            CATPartInterfaces \
                     CATMathematics \
        CATObjectSpecsModeler \
        CATGeometricObjects  \
        CATMathStream        \
        CATTopologicalObjects \
        CATTopologicalOperators  
=============================
error LNK2001: unresolved external symbol "__declspec(dllimport) class CATSolidSphere * __cdecl CATCreateSolidSphere(class CATGeoFactory *,class CATTopData *,class CATMathPoint const &,double)" (__imp_?CATCreateSolidSphere@@YAPAVCATSolidSphere@@PAVCATGeoFactory@@PAVCATTopData@@ABVCATMathPoint@@N@Z)
  
CATSolidSphere的 iMakeFile里面include什么呢?
作者: acoka    时间: 2004-9-27 17:03
CATTopologicalOperators
作者: acoka    时间: 2004-9-27 17:06
AddPrereqComponent("TopologicalOperators",Protected);  
作者: liketulip    时间: 2004-9-27 17:16
呵呵
OK
多谢acoka 大哥
我加了CATTopologicalOperators  
没加TopologicalOperators
作者: acoka    时间: 2004-9-27 17:34
你在哪里做呀?这么短时间,自学能到topologicaloperator的,算很快的
作者: liketulip    时间: 2004-9-28 11:36
我在北航
只是边做边学
一边参考帮助
因为看用到这个了
参考帮助上画球
CATGeoFactory* piGeomFactory = ::CATCreateCGMContainer() ;
CATMathPoint p1(0.,0.,0.);  // the sphere center
CATSoftwareConfiguration * pConfig = new CATSoftwareConfiguration();
CATTopData topdata(pConfig,NULL);
CATSolidSphere * pSphereOpe = ::CATCreateSolidSphere(piGeomFactory,  
&topdata,
p1,
100.0); // the radius
pSphereOpe -> Run();
CATBody * pBodySphere = pSphereOpe -> GetResult();
delete pSphereOpe; pSphereOpe=NULL;
pConfig->Release();
但是并没有画出来
作者: acoka    时间: 2004-9-28 12:06
你的Topdata没有journalReport, 用NULL定义了,画出来可多半不会被显示
很多东西不是执行了就可以显的
这些topologicaloperator常被用来做feature。
找个usecase里做实体的例子,画画看
catia里执行run的时候,最好放在CATTry里,免得systemdown
作者: liketulip    时间: 2004-9-28 12:20
推荐一个实例吧
没找到太合适的
只做了一个草图拉伸成实体的例子
作者: acoka    时间: 2004-9-30 13:44
\CAADoc\Doc\online\CAACgmBase\CAACgmTopologyHome.htm
里头有的是topo的例子呀
作者: liketulip    时间: 2004-10-8 15:00
CAADoc/Doc/online/CAATopUseCases/CAATopOverview.htm
这个例子绘制的模型如何在我的cmd下显示
我对基本的机制理解的还是不深
是不是要得到当前的窗口才行
我试了试还是不行了
他这个例子直接就是
CATGeoFactory* piGeomFactory = CATCreateCGMContainer() ;
CATPlane * piPlane = piGeomFactory->CreatePlane(CATMathOIJ);
if (NULL == piPlane)
{
::CATCloseCGMContainer(piGeomFactory);
}
作者: acoka    时间: 2004-10-8 15:26
CAADoc\Doc\online\CAADocUseCases\CAADocRunSample.htm
  
?
作者: liketulip    时间: 2004-10-8 15:36
不是这个意思
CAADoc/Doc/online/CAATopUseCases/CAATopOverview.htm  
这个例子在我的cmd绘制不出来
不知道是什么原因
是不是没有找到当前的window
还是其他原因
你不是也说了
绘制了并不一定能显示出来的
作者: liketulip    时间: 2004-10-8 15:47
我的意思是要把这个显示模型的例子能够在自己的cmd显示出来应该做怎样的修改呢?
我的函数是:
CATStatusChangeRC MyCmd::Activate( CATCommand * iFromClient, CATNotification * iEvtDat)
{  return (CATStatusChangeRCCompleted);
}
例子的函数是:
int main(int    iArgc,   // Number of arguments (0) or (1)  
         char** iArgv)   // Path to the *.NCGM document that will contain the result of the main.
{
    int rc=0;
    if(2<iArgc) return (1);
  
    char *pfileName = NULL;
    int  toStore = 0;
    if (2==iArgc)  
    {
    toStore = 1;  
    pfileName = iArgv[1];
    }
  
  //---------------------------------------------------------------------------
  // 1-Initializes the factory  
  //---------------------------------------------------------------------------
  
  CATGeoFactory* piGeomFactory = CATCreateCGMContainer() ;
    if (NULL == piGeomFactory) return (1);
    
    //---------------------------------------------------------------------------
  // 2- Creates the lines and circles of the profile
  //---------------------------------------------------------------------------
  
  CATPlane * piPlane = piGeomFactory->CreatePlane(CATMathOIJ);    // Geometrical plan
    if (NULL == piPlane)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
  CATMathPoint mathOrigin;
  CATMathDirection mathU, mathV;
  
  // ----------- Retrieves the mathematical definition of the geometrical plane
  piPlane->GetAxis(mathOrigin,mathU,mathV);
  
  // ----------- Defines points on the plane
    // Notice that we do not make any assumption on the plane parameterization.
    // The use of GetParam is allowed here, because the 3D points belong to the plane
    // by construction
  CATSurParam p1, p2, p3, p4, c1, c2;
  piPlane->GetParam(mathOrigin, p1);
  piPlane->GetParam(mathOrigin - 20*mathU                      , p2);
  piPlane->GetParam(mathOrigin - 10*mathU +    10*sqrt(3)  *mathV, p3);
  piPlane->GetParam(mathOrigin            +    10*sqrt(3)  *mathV, p4);
  piPlane->GetParam(mathOrigin - 20*mathU +    10          *mathV, c1);
  piPlane->GetParam(mathOrigin - 10*mathU + (10+10*sqrt(3))*mathV, c2);
  
  
  // ----------- Defines the curves of the profile
  const int nbPCurves = 5;
    CATPCurve *  aPCurves[nbPCurves];
  CATCrvLimits aLimits[nbPCurves];
  short        aOrientations[nbPCurves];
  aPCurves[0]=  piGeomFactory->CreatePLine   (p1, p2, piPlane );
  aPCurves[0] ->GetLimits(aLimits[0]);
  
  aPCurves[1]=  piGeomFactory->CreatePCircle (10, c1, CATPI/3, 3*CATPI/2, piPlane);
  aPCurves[1] ->GetLimits(aLimits[1]);
  
  aPCurves[2]=  piGeomFactory->CreatePCircle (10, c2, 4*CATPI/3, 3*CATPI/2, piPlane);
  aPCurves[2] ->GetLimits(aLimits[2]);
  
  aPCurves[3]=  piGeomFactory->CreatePLine   (p3, p4, piPlane );
  aPCurves[3] ->GetLimits(aLimits[3]);
  
  aPCurves[4]=  piGeomFactory->CreatePLine   (p4, p1, piPlane );
  aPCurves[4] ->GetLimits(aLimits[4]);
    for (int i=0; i<nbPCurves; i++)
    {
    if (NULL==aPCurves[i])
    {
      ::CATCloseCGMContainer(piGeomFactory);
      return (1);
    }
    }
  
  // Defines the orientations of the curves
    // This is needed by the CATTopSkin
  
  aOrientations[0] = 1;
  aOrientations[1] = 1;
  aOrientations[2] = 1;
  aOrientations[3] = 1;
  aOrientations[4] = 1;
  
  CATCrvParam low,high;
  CATMathPoint m1start, m1end, aPoints[2];
  
  // first checks the first two curves
  aLimits[0].GetExtremities(low,high);
  aPCurves[0]->Eval(low , CATCrvEvalCommand::EvalPoint, [$m1start)]
    aPCurves[0]->Eval(high, CATCrvEvalCommand::EvalPoint, [$m1end)]
  
    aLimits[1].GetExtremities(low,high);
  aPCurves[1]->Eval(low , CATCrvEvalCommand::EvalPoint, [$(aPoints[0]))]
    aPCurves[1]->Eval(high, CATCrvEvalCommand::EvalPoint, [$(aPoints[1]))]
  
    int index1, index2;
  double d1 = m1start.DistanceTo(aPoints,2,index1);
  double d2 =   m1end.DistanceTo(aPoints,2,index2);
  
    if (d1 < d2 )     // the orientation of the first curve is inverted
  {
    aOrientations[0] = -1;  
    if (1==index1) aOrientations[1] = -1;  // the orientation of the second curve is inverted
  }
  else
  {
    if (1==index2) aOrientations[1]= -1;  // the orientation of the second curve is inverted
  }
  
    // Checks now the other curves
  for (i=2;i<5;i++)
  {  
    m1end   = aPoints [1];
    if (-1==aOrientations[i-1]) m1end   = aPoints [0];
    
    aLimits[i].GetExtremities(low,high);
    aPCurves[i]->Eval(low , CATCrvEvalCommand::EvalPoint, [$(aPoints[0]))]
    aPCurves[i]->Eval(high, CATCrvEvalCommand::EvalPoint, [$(aPoints[1]))]
    
    d2 =   m1end.DistanceTo(aPoints,2,index2);
    if (1==index2) aOrientations[i]= -1;
  }
  
  // ---------- Builds the skin
    // Creates the operator
    CATSoftwareConfiguration * pConfig = new CATSoftwareConfiguration();
    CATTopData topdata(pConfig);
    CATTopSkin * pSkinOp = ::CATCreateTopSkin (piGeomFactory,
    &topdata,
    piPlane,
    nbPCurves,  
    aPCurves,
    aLimits,
    aOrientations);
    if (NULL==pSkinOp)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Runs
  pSkinOp->Run();
  
    // Gets the resulting body
  CATBody * piSkinBody = pSkinOp->GetResult();
    if (NULL==piSkinBody)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
    
    // Deletes the operator
  delete pSkinOp;
  pSkinOp = NULL;
  
  //---------------------------------------------------------------------------
  // 3- Creates a prism by using a topological operator
  //---------------------------------------------------------------------------
  CATMathDirection   zDir(0., 0., 1.);
  double startOffset = 10.;
    double endOffset   = 30.;
    CATTopPrism       *pPrismOp = ::CATCreateTopPrism (piGeomFactory,
    &topdata,
    piSkinBody,
    &zDir,
    startOffset,
    endOffset);
  
    if (NULL==pPrismOp)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
  // Runs
    pPrismOp->Run();
    
    // Gets the resulting body  
    CATBody * piMainBody1=NULL;
  piMainBody1 = pPrismOp->GetResult();
    if (NULL==piMainBody1)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Deletes the operator
  delete pPrismOp;
  pPrismOp = NULL;
  
  
  //---------------------------------------------------------------------------
  // 4- Creates a box primitive, a cylinder primitive: CATSolidPrimitive
  //---------------------------------------------------------------------------
  // ---------- Box
  CATMathPoint vO( -2., 2., 28.),  vOI(-2., 15., 28.), vOJ(-15., 2., 28.),  vOK(-2., 2., 35.);
  
    CATSolidCuboid *pCuboidOp = ::CATCreateSolidCuboid( piGeomFactory,  
    &topdata,  
    vO,  
    vOI,  
    vOJ,  
    vOK);
    if (NULL==pCuboidOp)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Gets the result (the operator is run at is creation)
  CATBody *piCuboidBody=NULL;
  piCuboidBody = pCuboidOp->GetResult();
    if (NULL==piCuboidBody)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Deletes the operator
  delete pCuboidOp;
  pCuboidOp = NULL;  
  
  // ---------- Cylinder
  CATMathPoint axisStart ( -20,  10,  20 ),  axisEnd( -20,  10, 32 );
  double       radius = 4.0;  
  
    CATSolidCylinder *pCylinderOp = ::CATCreateSolidCylinder(piGeomFactory,  
    &topdata,  
    axisStart,  
    axisEnd,  
    radius);
    if (NULL==pCylinderOp)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Gets the resulting body (the operator is run at its creation)
  CATBody *piCylinderBody = NULL;
  piCylinderBody = pCylinderOp->GetResult();
    if (NULL==piCylinderBody)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Deletes the operator
  delete pCylinderOp;
  pCylinderOp = NULL;
  
  //---------------------------------------------------------------------------
  // 5- Adds and Subtracts: Boolean operators
  //---------------------------------------------------------------------------
    CATDynBoolean* pBoolOp = ::CATCreateDynBoolean (piGeomFactory,
    &topdata,
    CATBoolUnion,  
    piMainBody1,  
    piCuboidBody);
    if (NULL==pBoolOp)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Runs
    pBoolOp->Run();
  
    // Gets the resulting body  
    CATBody * piMainBody2 = NULL;
  piMainBody2 = pBoolOp->GetResult();
    if (NULL==piMainBody2)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Deletes the operator
  delete pBoolOp;
  pBoolOp = NULL;
  
  piGeomFactory->Remove(piCuboidBody);      // Asks the factory to proceed the deletion (CATBody)  
    piCuboidBody = NULL;
  piGeomFactory->Remove(piMainBody1);
  piMainBody1 = NULL;
  
  // The removal
    pBoolOp = ::CATCreateDynBoolean (piGeomFactory,
    &topdata,
    CATBoolRemoval,  
    piMainBody2,  
    piCylinderBody);
    if (NULL==pBoolOp)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Runs
  pBoolOp->Run();
  
    // Gets the resulting body
    CATBody * piMainBody3 = NULL;
  piMainBody3 = pBoolOp->GetResult();
    if (NULL==piMainBody3)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Deletes the operator
  delete pBoolOp;
  pBoolOp = NULL;
  
  piGeomFactory->Remove(piCylinderBody);
  piCylinderBody = NULL;
  piGeomFactory->Remove(piMainBody2);
  piMainBody2 = NULL;
  
    //---------------------------------------------------------------------------
  // 6- Filleting
  //---------------------------------------------------------------------------
  
    // ---------- defines the edges to fillet
  CATLISTP(CATCell) listC;
  CATLISTP(CATCell) listFaces;
  piMainBody3 ->GetAllCells(listFaces, 2 );
  int nbFaces=listFaces.Size();  
  CATCell * piFace = NULL;
  
  // ---------- Recovers the only face with 2 internal loops
  
  for ( i=1;i<=nbFaces;i++)
  {
    if ( 3== (listFaces[i]->GetNbDomains()) ) piFace = listFaces[i];
  }
  
  // ---------- and the loop with 5 edges
  CATDomain * piLoop = NULL;  
  CATLISTP(CATEdge) listEdges;  
  int numberOfEdges;
  
  if (NULL != piFace)
  {
    for (i=1;i<=3;i++)
    {
      piLoop = piFace->GetDomain(i);
      if (NULL==piLoop)
      {
        ::CATCloseCGMContainer(piGeomFactory);
        return (1);
      }
      else
      {
        piLoop->GetAllCells(listC, 1);      
        numberOfEdges = listC.Size();
        if (5==listC.Size())
        {
          for (int j=1;j<=numberOfEdges;j++)
          {listEdges.Append((CATEdge *)listC[j]);}
        }
        
      }
    }
  }
  else // problem in the definition of the body
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (2);
    }
  
  // ---------- Defines the radius and ribbon
    // for a constant radius, only the first argument is useful
  CATDynFilletRadius * pRadius = new CATDynFilletRadius(1.,    // radius value
    NULL,  // the cell on which the radius is defined
    NULL,  // The ratio of the edge length defining the point
    NULL); // must be kept to NULL
    if (NULL==pRadius)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
  CATLISTP(CATDynFilletRadius)  listRadius;    
  listRadius.Append(pRadius);    
  CATDynEdgeFilletRibbon * pRibbon = new   CATDynEdgeFilletRibbon(listEdges, listRadius);
    if (NULL==pRibbon)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
  
    pRibbon ->SetSegmentationMode(CATDynTrim);
  
  // ----------- Creates the operator
    //
  CATDynFillet * pFilletOp = CATCreateDynFillet(piGeomFactory,[$topdata,piMainBody3)]
    if (NULL==pFilletOp)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
  
    // Appends the ribbon
    pFilletOp ->Append(pRibbon);
  
    // Runs
    pFilletOp ->Run();  
  
    // Gets the resulting body
    CATBody * piMainBody4 = NULL;
  piMainBody4 = pFilletOp->GetResult();
  
    if (NULL==piMainBody4)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Deletes the operator
  delete pFilletOp;
  pFilletOp = NULL;
  
  if (NULL != pRadius) delete pRadius;
  pRadius = NULL;
  if (NULL != pRibbon) delete pRibbon;
  pRibbon = NULL;
  
  piGeomFactory->Remove(piMainBody3);
  piMainBody3 = NULL;
  
  //---------------------------------------------------------------------------
  // 7- Shelling
  //---------------------------------------------------------------------------
  // ----------- Recovers the only face with 5 edges and without any internal loops
  //             that will be the opening of the shell
  listEdges.RemoveAll();
  piFace = NULL;
  for (i=1;i<=nbFaces;i++)
  {
    if ( 1== (listFaces[i]->GetNbDomains()) )  
    {
      piLoop = listFaces[i]->GetDomain(1);
      if (NULL==piLoop)
      {
        ::CATCloseCGMContainer(piGeomFactory);
        return (1);
      }
      else {
      piLoop ->GetAllCells(listC, 1);      
      numberOfEdges = listC.Size();
      if (5==listC.Size())
      {
        piFace=listFaces[i];
      }
      }
    }
  }
  
  if (NULL == piFace) return (3);
  
    // --------- Creates the shelling operator
    //
  CATDynShell* pShellOp = CATCreateDynShell (piGeomFactory,
    &topdata,
    piMainBody4,
    -1.,           // the first offset value
    0.);           // the second offset value
    if (NULL==pShellOp)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }  
    // Sets the opening faces
    CATLISTP(CATFace) openings;
  openings.Append((CATFace*)piFace);
    pShellOp-> Append(openings);  
    
    // Runs
  pShellOp->Run();
  
    // Gets the resulting body
    CATBody * piMainBody5 = NULL;
    piMainBody5 = pShellOp->GetResult();
    if (NULL==piMainBody5)
    {
    ::CATCloseCGMContainer(piGeomFactory);
    return (1);
    }
  
    // Deletes the operator
  delete pShellOp;
    pShellOp = NULL;
  
  piGeomFactory->Remove(piMainBody4,CATICGMContainer::RemoveDependancies);
  piMainBody4 = NULL;
  
  //---------------------------------------------------------------------------
  // 8- Gets the volume of the resulting body
  //---------------------------------------------------------------------------  
  CATDynMassProperties3D *pPropOp = CATDynCreateMassProperties3D (piMainBody5);
  if (NULL != pPropOp)
  {
    cout << "Volume of the final object" << pPropOp->GetVolume() << endl;
    delete pPropOp;
    pPropOp = NULL;
  }
  
    // Releases the configuration
    pConfig->Release();
  
  //---------------------------------------------------------------------------
  // 9- Writes the model
  //---------------------------------------------------------------------------
  cout << "Writing the model" << endl;
    if(1==toStore)
    {
    cout << "Writing the model" << endl;
#ifdef _WINDOWS_SOURCE
    ofstream filetowrite(pfileName, ios::binary ) ;
#else
    ofstream filetowrite(pfileName,ios::out,filebuf::openprot) ;
#endif
    
    ::CATSaveCGMContainer(piGeomFactory,filetowrite);
    filetowrite.close();
    }  
  //
  // Closes the container
  //
    ::CATCloseCGMContainer(piGeomFactory);
  return (rc);
}
作者: acoka    时间: 2004-10-8 15:53
不能放在activate里,
只要你的cmd从后台到前台,这个函数就会被自动呼叫,
你可以放在UpdateOKAction或OKAction里
  
你把main改成你的cmd的一个函数,OkAction里呼叫他就好
  
这样你按panel的OK的时候就会被呼叫
,可以这样来简单确认
作者: liketulip    时间: 2004-10-8 15:54
我加个按钮试试
作者: liketulip    时间: 2004-10-8 16:27
还是不行
没有显示绘制出来的图形
  
我的函数:
void TorusCmd::OnPushButton004PushBActivateNotification(CATCommand* cmd, CATNotification* evt, CATCommandClientData data)
  
我去掉了原来函数里的return(1)
作者: acoka    时间: 2004-10-8 16:31
被调用了?还是中间有错退出了?
作者: liketulip    时间: 2004-10-8 16:38
没有出错
函数肯定被调用了
图形没显示出来
CATPlane * piPlane = piGeomFactory->CreatePlane(CATMathOIJ);
里面的CATMathOIJ代表plane创建在什么平面上了?
作者: acoka    时间: 2004-10-8 16:43
自己定义个CATMathAxis好了
默认值是原点正交
  
return(1)是哪里的?
有些overwrite的函数改了返回值,默认呼叫的基底函数会变的
作者: liketulip    时间: 2004-10-8 16:46
函数我在前面贴出来了
原来它的函数不是int main()
返回值是int
我现在的函数是viod类型的
就在他的基础上改了改
应该没事吧
改出问题了?
作者: acoka    时间: 2004-10-8 16:47
  
  return(1)是哪里的?  
  
不会是
出错后return 1 吧
作者: acoka    时间: 2004-10-8 16:49
liketulip wrote:
函数我在前面贴出来了  
  原来它的函数不是int main()  
  返回值是int  
  我现在的函数是viod类型的  
  就在他的基础上改了改  
  应该没事吧  
  改出问题了?

  
原来的main()的return 1
基本都是取不到factory,或生成plane出错后,删除container后出错返回
作者: liketulip    时间: 2004-10-8 16:56
你的意思是我如何改?
作者: acoka    时间: 2004-10-8 17:04
int main() -> int createXXX()
  
  int ret = createXXX();
  if ( ret ) {
  // failed
  cout << " failed to create geo " << endl << flush ;
  }
作者: liketulip    时间: 2004-10-8 19:59
它说这个例子生成的是*.NCGM文件
是不是只能用CAAGemBrowser来打开阿
在CATIA中能显示吗?
作者: liketulip    时间: 2004-10-8 20:25
还是不能显示
int iArgc = 0;
char **iArgv = NULL;
int ret = CreateModle(iArgc, iArgv);  
-----------------------------------------------------------
int TorusCmd::CreateModle(int iArgc, char **iArgv)
{}
  
另外
那个CAATopOverview运行也没有找到生成Overview.NCGM
这个格式的文件CATIA是打不开的,用CAAGemBrowser能打开
所以不知道在cmd下面把这段加上能不能在CATIA显示出来
作者: acoka    时间: 2004-10-9 00:49
liketulip wrote:
还是不能显示  
  int iArgc = 0;  
  char **iArgv = NULL;  
  int ret = CreateModle(iArgc, iArgv);   
  -----------------------------------------------------------  
  int TorusCmd::CreateModle(int iArgc, char **iArgv)  
  {}  
  
  另外  
  那个CAATopOverview运行也没有找到生成Overview.NCGM  
  这个格式的文件CATIA是打不开的,用CAAGemBrowser能打开  
  所以不知道在cmd下面把这段加上能不能在CATIA显示出来

  
今天开始回国1周,没有电脑环境了
作者: liketulip    时间: 2004-10-9 09:26
不来北京吧?




欢迎光临 iCAx开思工具箱 (https://t.icax.org/) Powered by Discuz! X3.3