[ORD c++] How to use the corridor::GetXSCutPoints() API?

My ORD and ORD sdk are all update5 version.

When i try to get the bvector<XSCutPoint> by following code:

DgnModelP modelP = ISessionMgr::GetActiveDgnModelP();

csConnect = ConsensusConnection::Create(*dgnModel);
csModel = ConsensusModel::Create(*dgnModel);

GeometricModelPtr geomModel = csModel->GetActiveGeometricModel();

auto corridors = geomModel->GetCorridors();
if (corridors.IsValid()&&corridors->MoveNext())
	{
		corridors->Reset();
		while (corridors->MoveNext())
		{
			CorridorPtr corri = corridors->GetCurrent();
			bvector<XSCutPoint> points;
			corri->GetXSCutPoints(2, 40, 40, 2, points);
			
			for each(XSCutPoint point in points)
			{
			    mdlDialog_dmsgsPrint(L"GetXSCutPoint");
			}
		}
	}

it get wrong on the second object in bvector<XSCutPoint> 

do i use the GetXSCutPoints() function in correct way?

  • The problem may be that the GetXSCutPoints uses the ConsensusItemCache .  Therefore, the caller should set the cache before and after calls to GetXSCutPoints.

     

    In C++ the call is:

    ConsensusItemCache::GetInstance()->SetCaching(true);

    and

    ConsensusItemCache::GetInstance()->SetCaching(false);

     If you are going to make multiple calls to GetXSCutPoints, you should set and clear the cache outside of the loop.  See the code below.  

    Also, I don’t think you need the highlighted MoveNext in the if statement.

    NOTE: The leftOffset value should typically be the distance from the centerline to the offset of the leftWidth, where to the left of centerline is negative and to the right is positive. 

    I hope this helps.

    DgnModelP modelP = ISessionMgr::GetActiveDgnModelP();

     

    csConnect = ConsensusConnection::Create(*dgnModel);

    csModel = ConsensusModel::Create(*dgnModel);

     

    GeometricModelPtr geomModel = csModel->GetActiveGeometricModel();

     

    auto corridors = geomModel->GetCorridors();

    if (corridors.IsValid() && corridors->MoveNext())

        {

        corridors->Reset();

        while (corridors->MoveNext())

            {

            CorridorPtr corri = corridors->GetCurrent();

            bvector<XSCutPoint> points;

            ConsensusItemCache::GetInstance()->SetCaching(true);

            double startStation = 0.0;

            double endStation = 500.0;

            double increment = 100.0;

            for (double station = startStation; station < endStation; station += increment)

                {

                double leftWidth = 40.0;

                double rigthWidth = 40.0;

                double leftOffset = -leftWidth;

                bvector<XSCutPoint> points;

                corri->GetXSCutPoints(station, leftWidth, rigthWidth, leftOffset, points);

                for each(XSCutPoint point in points)

                    {

                    mdlDialog_dmsgsPrint(L"GetXSCutPoint");

                    }

                }

            ConsensusItemCache::GetInstance()->SetCaching(false);

            }

        }

    Answer Verified By: wanglin 

  • thanks a lot for solve my problem. But there is an other problem: I can't find the ConsensusItemCache in the SDK include folder.

  • Unfortunately, we failed to deliver that .h file in the SDK.  The call is accessible if you use the C# SDK.  I will file a defect to have ConsensusItemCache.h  delivered in a future release.

    Answer Verified By: wanglin 

  • OK, hope that will coming soon. I will try the c# SDK in the next step. Thank you!