添加项目文件。
This commit is contained in:
52
MstnAPIAssist/Managed/ElementHelper.cpp
Normal file
52
MstnAPIAssist/Managed/ElementHelper.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "../pch.h"
|
||||
#include "ElementHelper.h"
|
||||
#include <vector>
|
||||
#include <msclr/marshal.h>
|
||||
#include "../Native/CElementHelper.h"
|
||||
|
||||
void BRDI::MstnAPI::ElementHelper::CreateLineElement(GeomNet::DPoint3d startPoint, GeomNet::DPoint3d endPoint)
|
||||
{
|
||||
DPoint3dCP pStartPoint = reinterpret_cast<DPoint3dCP>(&startPoint); // GeomNet::DPoint3d是值类型,位于调用栈,不需要固定,直接取地址
|
||||
DPoint3dCP pEndPoint = reinterpret_cast<DPoint3dCP>(&endPoint);
|
||||
CElementHelper elemHelper;
|
||||
elemHelper.CreateLineElement(pStartPoint, pEndPoint);
|
||||
}
|
||||
|
||||
void BRDI::MstnAPI::ElementHelper::CreateLineStringElement(array<GeomNet::DPoint3d>^ points)
|
||||
{
|
||||
pin_ptr<GeomNet::DPoint3d> pPoints = &points[0]; // array<GeomNet::DPoint3d>^位于托管堆,需要先固定
|
||||
DPoint3dCP pNativePoint = reinterpret_cast<DPoint3dCP>(pPoints);
|
||||
int pointCount = points->Length;
|
||||
CElementHelper elemHelper;
|
||||
elemHelper.CreateLineStringElement(pNativePoint, pointCount);
|
||||
}
|
||||
|
||||
void BRDI::MstnAPI::ElementHelper::CreateCurveElement(GeomNet::CurveVector^ curveVector)
|
||||
{
|
||||
CurveVectorCP pCurveVector = static_cast<CurveVectorCP>(GeomNet::CurveVector::DereferenceToNative(curveVector, false).ToPointer());
|
||||
CElementHelper elemHelper;
|
||||
elemHelper.CreateCurveElement(pCurveVector);
|
||||
}
|
||||
|
||||
void BRDI::MstnAPI::ElementHelper::BodyFromLoft(array<GeomNet::CurveVector^>^ profiles, DgnPlatformNET::DgnModelRef^ dgnModelRef)
|
||||
{
|
||||
std::vector<CurveVectorPtr> curveVectorPtrs;
|
||||
for each (GeomNet::CurveVector ^ profile in profiles)
|
||||
{
|
||||
CurveVectorPtr pCurveVector = static_cast<CurveVectorP>(GeomNet::CurveVector::DereferenceToNative(profile, false).ToPointer());
|
||||
curveVectorPtrs.push_back(pCurveVector);
|
||||
}
|
||||
|
||||
int profileCount = profiles->Length;
|
||||
DgnModelRefP pDgnModelRef = static_cast<DgnModelRefP>(dgnModelRef->GetNative().ToPointer());
|
||||
CElementHelper elemHelper;
|
||||
elemHelper.BodyFromLoft(&curveVectorPtrs[0], profileCount, pDgnModelRef);
|
||||
}
|
||||
|
||||
void BRDI::MstnAPI::ElementHelper::ShowMessage(String^ message)
|
||||
{
|
||||
msclr::interop::marshal_context context;
|
||||
WCharCP msg = context.marshal_as<WCharCP>(message);
|
||||
CElementHelper elemHelper;
|
||||
elemHelper.ShowMessage(msg);
|
||||
}
|
||||
Reference in New Issue
Block a user