Conversion 2D/3D

Everything DG Kernel: Technical discussions and issues
Post Reply
useme
Posts: 5
Joined: Fri Feb 21, 2025 6:06 pm

Conversion 2D/3D

Post by useme »

In the documentation for Arc Spline Curves https://dynoinsight.com/Help/V7_2/AX/Ge ... Curve.aspx it is stated that "The frames can be accessed by querying IFrameArray_DG from IArcSpline3DCurve_DG". Please give me a hint on how to do that, I cannot find a method to query this array from a IArcSpline3DCurve_DG previously defined through individual points, normals and curvatures. Thanks!
Mike Zubovic
Posts: 44
Joined: Mon Jul 15, 2024 5:20 am

Re: Conversion 2D/3D

Post by Mike Zubovic »

Hello useme

Please try something like this:
IFrameArray_DG iFrameArr = theCurve.Query<IFrameArray_DG>();

If you search for IFrameArray_DG in the samples, you will find a debuggable working example in eMotion sample.

Regards
useme
Posts: 5
Joined: Fri Feb 21, 2025 6:06 pm

Re: Conversion 2D/3D

Post by useme »

Hi Nick,

I have tried unsuccessfully the equivalent in Visual Studio 2022 in VB: iFrameArr=TryCast(iPath, IFrameArray_DG), being iPath defined as Dim iPath As IArcSpline3DCurve_DG = m_gen.Create("IArcSpline3DCurve_DG") and iFrameArr as IFrameArray_DG=m_gen.Create("IFrameArray_DG"). I also tried iFrameArr=iPath. Does not work.

In fact inspired by the eMotion sample I was seeking to define a general IMove_DG by a generic trajectory as IArcSpline3DCurve_DG following the procedure next:

Dim R As Double = 2 'just for trial purposes
'0. DECLARATIONS
Dim iMove As IMove_DG = m_gen.Create("IMove_DG")
'iMove.CreateAttributes(MoveParametrisationType_DG.eMoveParametrisationTypeArcSpline)
Dim iPath As IArcSpline3DCurve_DG = m_gen.Create("IArcSpline3DCurve_DG")
'Dim iPath As IArcSpline3DCurve_DG = m_gen.Create(EObjectType.eObjTypeArcSplineCurve)
Dim iCurve As ICurveFreeForm_DG = m_gen.Create("ICurveFreeForm_DG")
Dim iPoints As IPointArray_DG = iCurve.GetData()
If iPoints.GetCount() = -1 Then Return Nothing
'1. DEFINE SPLINE POINTS
iPoints.SetCount(4) 'Two ends of the arc
'iPoint = SplinePoints
iPoints.SetPoint1(0, 0, 0, 0)
iPoints.SetPoint1(1, -1, 0, 0)
iPoints.SetPoint1(2, -2, 0, 0)
iPoints.SetPoint1(3, -4, 0, 0)
'
'2. DEFINE SPLINE
Dim radii As IArrayDouble_DG = m_gen.Create("IArrayDouble_DG")
radii.SetCount(iPoints.GetCount())
For i As Integer = 0 To iPoints.GetCount() - 1
radii.SetAt(i, R)
Next
iPath = iCurve.ConstructFilletedLineStrip(radius:=R)
'3. DEFINE NORMALS
Dim iNormals As IPointArray_DG = iPath.GetSplineNormals()
Debug.WriteLine("Normals={0:N0}", iNormals.GetCount())
iNormals.SetPoint(0, createP(0, 1, 0)) ' Plane of the arc is parallel to x,z plane
'
'4. DEFINE CURVATURES
Dim iCurvatures As IArrayDouble_DG = iPath.GetCurvatureArray()
Debug.WriteLine("Curvatures={0:N0}", iCurvatures.GetCount())
iCurvatures.SetAt(0, 1 / R)
'5. DEFINE MOVEMENT
iMove.SetOriginPath(iPath)
iMove.DefineTangential()
'
Debug.WriteLine("iMove defined")
'
'iFrameArr = iMove.GetFrameArray()
iFrameArr = iPath
'iFrameArr = TryCast(iPath, IFrameArray_DG)
Debug.WriteLine("Number= " & iFrameArr.ToString)

And was expecting to have a FrameArray that could be used in KinematicSet with other objects...

I am stucked. Sorry if there is an evident error that I cannot identify by myself.

Best regards,
Marcos
Mike Zubovic
Posts: 44
Joined: Mon Jul 15, 2024 5:20 am

Re: Conversion 2D/3D

Post by Mike Zubovic »

You are right. We have reproduced it in a small test. There is a bug in the IArcSpline3DCurve_DG > IFrameArray_DG query in the internal DGK code.
There should be an update soon.
Thank you for reporting.
Regards
Mike Zubovic
Posts: 44
Joined: Mon Jul 15, 2024 5:20 am

Re: Conversion 2D/3D

Post by Mike Zubovic »

We have posted 7.3.5607 and 7.2.5608 with a fix for the query.

I did not analyze closely your code. We have tested it with InterfaceTests.IArcSpline3DCurve_DGTst.FrameArrayTest(). It is in the installed v7.3 code now.

We have also tested its C++ copy:

Code: Select all

void IArcSpline3DCurve_DGTest::T1()
{
    IArcSpline3DCurve_DGPtr arcSplineCurve;
    m_gen->Create("IArcSpline3DCurve_DG", (IUnknown**)&arcSplineCurve);        ASSERT(arcSplineCurve);
    ICurveFreeForm_DGPtr fformCurve = arcSplineCurve;
    IPointArray_DGPtr points;
    fformCurve->GetData(&points);
    points->SetCount(3);
    PointDg pt;
    points->SetPoint(0, &pt);
    pt.Set(2, 0, 0);
    points->SetPoint(1, &pt);
    pt.Set(2, 0, 2);
    points->SetPoint(2, &pt);

    IArrayDouble_DGPtr curvatures;
    arcSplineCurve->GetCurvatureArray(&curvatures);
    curvatures->SetAt(0, 0.5);      // Radius 2.0
    curvatures->SetAt(1, -1.0);     // Radius 1.0. Center on the right

    IFrameArray_DGPtr iFrameArray = arcSplineCurve;
    ASSERT(iFrameArray);

    IFrame_DGPtr frame0;
    iFrameArray->GetFrame(0, &frame0);
    frame0->Rotate4(0.5 * dPi, 0);         // Rotate by PI/2 around x-axis

    // frame0 a copy, not a reference. So, we need to call SetFrame to update the frame in the array.
    iFrameArray->SetFrame(0, frame0);

    IFrame_DGPtr frame1;
    iFrameArray->GetFrame(1, &frame1);
    frame1->Rotate4(0.25 * dPi, 0);         // Rotate by PI/4 around the local x-axis

    iFrameArray->SetFrame(1, frame1);

    IObject_DGPtr iObject = arcSplineCurve;
    IScene_DGPtr iScene = m_iView;

    iScene->CreatePresentationEntity(iObject, true, nullptr, nullptr);

    m_iView->Reset(true, true);
}
In this case iFrameArray->SetFrame(1, frame1); behaves little funny. It is basically only a way to modify normal of the plane of the spline to z axis of the frame. Everything else is defined using the underlying point array. We have updated the relevant docs topic for that.

Regards
Post Reply