Hello,
My system is windows 7, vs 2015 and CE update 11
My quastion is about mdlSolid_closestPointOnBody
When body is primitive solid output distance is correct.
However, if body is smart solid, output distance is wrong.
In both cases, output PointOutP is correct.
Appriciate any help.
Thanks
Nenad
Nenad Poljcic said:if body is smart solid, output distance is wrong
The MicroStationAPI documentation for that function tells us: distanceP is the distance from the test point to the closest point in solid kernel units. How are you converting from solid kernel units to master units? Show some code!
distanceP
Regards, Jon Summers LA Solutions
Hi Jon,
I think function returns different units for primitive solid and smart solid.
This is the code:
mdlSolid_beginCurrTrans(MASTERFILE); DPoint3d pntIn; Transform * bodyTransform; StatusInt iSuccess; double dist; DPoint3d pointOutP ; ENTITY_TAG entityOutPP ; BODY_TAG pKIBody = NULL; Bentley::Transform bodyTransformP; //create body iSuccess = mdlSolid_elementToBody(&pKIBody, &bodyTransformP, pElm, ACTIVEMODEL); mdlSolid_closestPointOnBody(&pointOutP, &entityOutPP, &dist, pKIBody, bodyTransform, &pntIn, ACTIVEMODEL);
Nenad Poljcic said:I think function returns different units for primitive solid and smart solid
Bentley::Transform bodyTransformP; iSuccess = mdlSolid_elementToBody(&pKIBody, &bodyTransformP, pElm, ACTIVEMODEL);
You're passing an uninitialised pointer for bodyTransform. MicroStationAPI help tells us: bodyTransformP is the currtrans scaled transform from solid kernel coordinates to MicroStation coordinates.
bodyTransform
bodyTransformP
If you scale the distance found by mdlSolid_closestPointOnBody(), using that transform, do you get a better result?
mdlSolid_closestPointOnBody()
How do I scale distance using transform?
thanks
Nenad Poljcic said:How do I scale distance using transform?
From MicroStationAPI help: double Transform::ColumnXMagnitude () const Return magnitude of X column. This is commonly considered as the scale factor of the transform.
double Transform::ColumnXMagnitude () const
I recommend using the C++ SolidUtil api for new code, it's much easier to use/understand than the old mdlSolid api with it's mdlcurrtrans.
You would use SolidUtil::Convert::ElementToBody (or ElementToBodies) to get ISolidKernelEntity(s) from an element's geometry. You can then call SolidUtil::ClosestPoint to get back the closest point on the body from the supplied point.
Input and output coordinates are always uors, so no mdlcurrtrans or body->uor transform to take into account. If you want the distance, just call testPoint.Distance(closePoint).
HTH
Answer Verified By: Nenad Poljcic
Hi Brian,
Thanks, I'll try it