我用C#\C++混合编程,调用mdlBspline_surfaceFromRailsAndSweptSections (pSurface, pRail1, pRail2, pSection1, pSection2, numSections, skinTolerance, skinDirection, bSectionRotate, bSectionRotationAxisFromRail0, bSectionOrthogonality, bSectionScale, bSectionScaleUniformly)。
对于曲线我都有memset(§ion1, 0, sizeof(section1)),并且尝试各种参数组合,获得的Surface Element都是无效的,
请问mdlBspline_surfaceFromRailsAndSweptSections这个函数应该怎么使用?
代码如下:
DgnModel dgnModel = Session.Instance.GetActiveDgnModel(); long id1 = 982; Element rail1 = dgnModel.FindElementById((ElementId)id1); long id2 = 984; Element rail2 = dgnModel.FindElementById((ElementId)id2); long id3 = 1051; Element section1 = dgnModel.FindElementById((ElementId)id3); long id4 = 1053; Element section2 = dgnModel.FindElementById((ElementId)id4); Element surfaceEle = OrdSurfaceHelper.CreateSplineSurfaceBySweepTwoCurves(rail1, rail2, section1, section2 , 2, 0.001, 0, false, false, false, true, true);
static BDE::Element^ CreateSplineSurfaceBySweepTwoCurves ( BDE::Element^ pRail1, BDE::Element^ pRail2, BDE::Element^ pSection1, BDE::Element^ pSection2, int numSections, double skinTolerance, int skinDirection, bool bSectionRotate, bool bSectionRotationAxisFromRail0, bool bSectionOrthogonality, bool bSectionScale, bool bSectionScaleUniformly );
文件如下:
扫略试验.dgn
该函数为一个未公开的C函数,请先在纯C/C++环境下调用成功后再在混合环境下调用,这样可以排除你混合编程造成的问题。以前郭老师曾经写过一个调用成功的例子如下:
extern "C" StatusInt mdlBspline_surfaceFromRailsAndSweptSections ( MSBsplineSurface* pSurface, const MSBsplineCurve* pRail0, const MSBsplineCurve* pRail1, const MSBsplineCurve* pSection0, const MSBsplineCurve* pSection1, int numSections, double skinTolerance, int skinDirection, BoolInt bSectionRotate, BoolInt bSectionRotationAxisFromRail0, BoolInt bSectionOrthogonality, BoolInt bSectionScale, BoolInt bSectionScaleUniformly ); void TestSweepTwoAlongOne() { MSBsplineSurface msBspSurface; memset(&msBspSurface, 0, sizeof(msBspSurface)); EditElementHandle eehPath(7156, ACTIVEMODEL); EditElementHandle eehProfile1(7155, ACTIVEMODEL); EditElementHandle eehProfile2(7158, ACTIVEMODEL); CurveVectorPtr cvevcrPtr = ICurvePathQuery::ElementToCurveVector(eehPath); MSBsplineCurvePtr msBspCvePtrPath = cvevcrPtr->GetBsplineCurve(); cvevcrPtr = ICurvePathQuery::ElementToCurveVector(eehProfile1); MSBsplineCurvePtr msBspCvePtrPro1 = cvevcrPtr->GetBsplineCurve(); cvevcrPtr = ICurvePathQuery::ElementToCurveVector(eehProfile2); MSBsplineCurvePtr msBspCvePtrPro2 = cvevcrPtr->GetBsplineCurve(); if (SUCCESS != mdlBspline_surfaceFromRailsAndSweptSections(&msBspSurface, &*msBspCvePtrPath, NULL, &*msBspCvePtrPro1, &*msBspCvePtrPro2, 2, 0, BSSURF_U / BSSURF_V, FALSE, TRUE, TRUE, TRUE, TRUE)) { return; } EditElementHandle eehResult; DraftingElementSchema::ToElement(eehResult, msBspSurface, NULL, *ACTIVEMODEL); eehResult.AddToModel(); }
Answer Verified By: Tee Lee
谢谢符工范例,试了曲面可以出来了。