找回密码 注册 QQ登录
一站式解决方案

iCAx开思网

CAD/CAM/CAE/设计/模具 高清视频【积分说明】如何快速获得积分?快速3D打印 手板模型CNC加工服务在线3D打印服务,上传模型,自动报价
打印 上一主题 下一主题

【求助】CAA草图的旋转用什么函数

[复制链接]
21
发表于 2004-9-27 17:16:56 | 只看该作者
呵呵
OK
多谢acoka 大哥
我加了CATTopologicalOperators  
没加TopologicalOperators
22
发表于 2004-9-27 17:34:31 | 只看该作者
你在哪里做呀?这么短时间,自学能到topologicaloperator的,算很快的
23
发表于 2004-9-28 11:36:47 | 只看该作者
我在北航
只是边做边学
一边参考帮助
因为看用到这个了
参考帮助上画球
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();
但是并没有画出来
24
发表于 2004-9-28 12:06:04 | 只看该作者
你的Topdata没有journalReport, 用NULL定义了,画出来可多半不会被显示
很多东西不是执行了就可以显的
这些topologicaloperator常被用来做feature。
找个usecase里做实体的例子,画画看
catia里执行run的时候,最好放在CATTry里,免得systemdown
25
发表于 2004-9-28 12:20:08 | 只看该作者
推荐一个实例吧
没找到太合适的
只做了一个草图拉伸成实体的例子
26
发表于 2004-9-30 13:44:11 | 只看该作者
\CAADoc\Doc\online\CAACgmBase\CAACgmTopologyHome.htm
里头有的是topo的例子呀
27
发表于 2004-10-8 15:00:23 | 只看该作者
CAADoc/Doc/online/CAATopUseCases/CAATopOverview.htm
这个例子绘制的模型如何在我的cmd下显示
我对基本的机制理解的还是不深
是不是要得到当前的窗口才行
我试了试还是不行了
他这个例子直接就是
CATGeoFactory* piGeomFactory = CATCreateCGMContainer() ;
CATPlane * piPlane = piGeomFactory->CreatePlane(CATMathOIJ);
if (NULL == piPlane)
{
::CATCloseCGMContainer(piGeomFactory);
}
28
发表于 2004-10-8 15:26:33 | 只看该作者
CAADoc\Doc\online\CAADocUseCases\CAADocRunSample.htm
  
?
29
发表于 2004-10-8 15:36:25 | 只看该作者
不是这个意思
CAADoc/Doc/online/CAATopUseCases/CAATopOverview.htm  
这个例子在我的cmd绘制不出来
不知道是什么原因
是不是没有找到当前的window
还是其他原因
你不是也说了
绘制了并不一定能显示出来的
30
发表于 2004-10-8 15:47:59 | 只看该作者
我的意思是要把这个显示模型的例子能够在自己的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);
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3D打印手板模型快速制作服务,在线报价下单!

QQ 咨询|手机版|联系我们|iCAx开思网  

GMT+8, 2024-12-24 02:51 , Processed in 0.027935 second(s), 9 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表