|
下面是示例代码,求端点是(0 0 0) (0 0 1)的LINE和Su**ce的交点。
注意:include和lib文件在 ObjectARX SDK\\utils\brep 目录下。- static AcGePoint3dArray Intersect(AcDbSu**ce* pSu**ce,AcGeLine3d line)
- {
- AcGePoint3dArray returnPtArray;
- AcDbBody* pBody = new AcDbBody();
- // 2013
- // Acad::ErrorStatus es = pBody->setASMBody(pSu**ce->ASMBodyCopy());
- //before 20123
- Acad::ErrorStatus es = pBody->setBody(pSu**ce->body());
- //build AcBrBrep
- AcBrBrep* pBrep = new AcBrBrep();
- //
- if(AcBr::eOk == pBrep->set(*pBody))
- {
- AcBrBrepFaceTraverser* pFaceTrav = new AcBrBrepFaceTraverser;
- if(AcBr::eOk == pFaceTrav->setBrep(*pBrep))
- {
- for(pFaceTrav->restart();!pFaceTrav->done();pFaceTrav->next())
- {
- AcB**ce face;
- if(AcBr::eOk == pFaceTrav->getFace(face))
- {
- double area = 0.0f;
- face.getSu**ceArea(area);
- acutPrintf(L"\nSu**ce Area: %f", area);
- //*****whole su**ce of the Brep face******
- //AcGeNurbSu**ce nurbSu**ce;
- //face.getSu**ceAsNurb(nurbSu**ce);
- //AcGeCurveSurfInt curveSI;
- ////input the curve and line
- //curveSI.set(line,nurbSu**ce);
- ////get the count of intersect points
- //int count = curveSI.numIntPoints(err采用1);
- // if(err采用1 == AcGe::kXXOk && count >0 )
- // {
- // AcGeIntersectError err采用2;
- // for(int index = 0 ;index < count; index ++)
- // {
- // AcGePoint3d pt =
- // curveSI.intPoint(index,err采用2);
- // returnPtArray.append(pt);
- // }
- //
- // }
- //**********
- //****real su**ce of the orignal AcDbSu**ce
- AcGeExternalBoundedSu**ce** nurbs = NULL;
- Adesk::UInt32 numNurbs = 0;
- face.getSu**ceAsTrimmedNurbs(numNurbs,nurbs);
- //*****
- for (Adesk::UInt32 i = 0; i < numNurbs; i++)
- {
- AcGeCurveSurfInt curveSI;
- AcGeIntersectError err采用1 = AcGe::kXXOk;
- //input the curve and line
- curveSI.set(line,*nurbs<i>);
- //get the count of intersect points
- int count = curveSI.numIntPoints(err采用1);
- if(err采用1 == AcGe::kXXOk && count >0 )
- {
- AcGeIntersectError err采用2;
- for(int index = 0 ;index < count; index ++)
- {
- AcGePoint3d pt =
- curveSI.intPoint(index,err采用2);
- returnPtArray.append(pt);
- }
- }
- delete nurbs<i>;
- }
- // your responsibility to delete the
- // array of su**ces
- delete[] nurbs;
- }
- }
- }
- delete pFaceTrav;
- }
- delete pBrep;
- return returnPtArray;
- }
复制代码 |
|