计算草图的中心点以及草图中心点

输入:

            (1)CATIGSMFactory_var         ispGsmFactory            GSM工厂类

            (2) CATISketch_var                 ispSketch                      输入草图

// 计算原始草图的法向

CATISpecObject_var             spPlanarSupport = NULL_var;

CATMathPlane                      mathPlaneSk;

CATMathVector                     mathNormal = CATMathVector();

CATMathVector                    mathFirstDirect = CATMathVector();

CATMathVector                   mathSecondDirect = CATMathVector();

if (SUCCEEDED(ispSketch->GetPlanarSupport(spPlanarSupport)))

{

            CATPlane_var spPlane= spPlanarSupport;

            if(NULL_var != spPlane)

            {

                    spPlane->GetAxis(mathPlaneSk);

                    mathPlaneSk.GetNormal(mathNormal);

                    mathPlaneSk.GetFirstDirection(mathFirstDirect);

                    mathPlaneSk.GetSecondDirection(mathSecondDirect);

                    mathFirstDirect.Normalize();

                    mathSecondDirect.Normalize();

                    mathNormal.Normalize();

            }

            else

            {

                return S_FALSE;

            }

}

// 计算草图所在的Body

CATIGeometricalElement_var spSketchGeomElem = ispSketch;

if (NULL_var == spSketchGeomElem)

{

            return S_FALSE;

}

CATBody_var spBodyOfSketch = NULL_var;

spBodyOfSketch = spSketchGeomElem->GetBodyResult();

if (NULL_var == spBodyOfSketch)

{

        return S_FALSE;

}

// 计算草图的包围盒

CATMathBox mathBoundingBox;

mathBoundingBox = spBodyOfSketch->GetBoundingBox();

CATMathPoint mathHighPoint; // 最大值点

CATMathPoint mathLowPoint; // 最小值点

mathBoundingBox.GetHighLimit(mathHighPoint);

mathBoundingBox.GetLowLimit(mathLowPoint);

// 计算草图的中心点

double dXVal = (mathHighPoint.GetX() + mathLowPoint.GetX())*0.5;

double dYVal = (mathHighPoint.GetY() + mathLowPoint.GetY())*0.5;

double dZVal = (mathHighPoint.GetZ() + mathLowPoint.GetZ())*0.5;

CATMathPoint mathOriginPnt = CATMathPoint(dXVal,dYVal,dZVal);

你可能感兴趣的:(计算草图的中心点以及草图中心点)