Files
MsAddIns/MstnAPIAssist/Managed/ElementHelper.cpp
2026-02-28 21:01:57 +08:00

52 lines
2.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#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);
}