Hi, anyone has experiences about API function - SetClipBoundary(...) of IPointCloudEdit ? I have implemented the clip boundary function as bellows, in the code I have confirmed "handlerP" pointer is correct, but handlerP->SetClipBoundary is occur error at all times(Occur MicroStation Application error).
///////////////////////////////////////////////////////////////////////////////////////////////////////////
bool CDreamBimPointCloudAPI::ClipInsidePointsOfPolyfonFence(std::vector<DPoint3d> rPolygonFence)
{
Bentley::Ustn::Element::EditElemHandle *pEeh;
for (long i = 0; i < g_rEditElementHandle.size(); i++) { if (!g_rEditElementHandle[i]) continue;
pEeh = g_rEditElementHandle[i]; Bentley::Ustn::Element::PointCloudHandler* handlerP = CastPointCloudHandler(pEeh);
handlerP->SetClipBoundary(*pEeh, rPolygonFence);
}
return true;
------------------------------------
e1seop.
Unknown said:g_rEditElementHandle
What is the declaration of that variable?
Unknown said:CastPointCloudHandler
What is the implementation of that function?
Regards, Jon Summers LA Solutions
related source code as followings.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Bentley::Ustn::Element::PointCloudHandler* g_handlerPointCloud = NULL;std::vector<Bentley::Ustn::Element::EditElemHandle*> g_rEditElementHandle;
std::vector<DPoint3d> g_rPickedPointsInPointCloudTool;
// casting point cloud handlerBentley::Ustn::Element::PointCloudHandler* CastPointCloudHandler(Bentley::Ustn::Element::EditElemHandle *pEeh){ if (!pEeh) return NULL;
Bentley::Ustn::Element::PointCloudHandler* handlerP = dynamic_cast<Bentley::Ustn::Element::PointCloudHandler*>(&pEeh->GetHandler ());
return handlerP;}
// model scan
int CollectElmsCallback (ElementRef elemRef,void* callbackArg, ScanCriteria* scP){ DgnModelRefP modelP (mdlScanCriteria_getModel (scP)); Bentley::Ustn::Element::EditElemHandle *pEeh = new Bentley::Ustn::Element::EditElemHandle (elemRef, modelP);
Bentley::Ustn::Element::PointCloudHandler* handlerP = CastPointCloudHandler(pEeh); if (NULL != handlerP) { // point cloud handler is unique.. g_handlerPointCloud = handlerP;
// point cloud edit element handler
g_rEditElementHandle.push_back(pEeh); } else { g_handlerPointCloud = NULL; }
return SUCCESS;}
// model 을 scan scan 하면서 point cloud handler를 받아온다.void CDreamBimPointCloudAPI::CollectPointCloud_Handler(){ // free for (long i = 0; i < g_rEditElementHandle.size(); i++) { if (!g_rEditElementHandle[i]) continue;
delete g_rEditElementHandle[i]; } g_rEditElementHandle.clear();
DgnModelRefP modelRef = NULL; ScanCriteriaP scP = mdlScanCriteria_create ();
mdlScanCriteria_setModel (scP, ACTIVEMODEL); mdlScanCriteria_setReturnType (scP, MSSCANCRIT_ITERATE_ELMREF, false, true); mdlScanCriteria_setElemRefCallback (scP, CollectElmsCallback, NULL); mdlScanCriteria_addSingleElementTypeTest (scP, EXTENDED_ELM); mdlScanCriteria_scan (scP, NULL, NULL, NULL); mdlScanCriteria_free (scP);}
bool CDreamBimPointCloudAPI::ClipInsidePointsOfPolyfonFence(std::vector<DPoint3d> rPolygonFence){ // point cloud handler CollectPointCloud_Handler(); ASSERT(g_handlerPointCloud);
Bentley::Ustn::Element::EditElemHandle *pEeh; Bentley::WString name; char* out = NULL; Transform trn;
for (long i = 0; i < g_rEditElementHandle.size(); i++) { if (!g_rEditElementHandle[i]) continue; pEeh = g_rEditElementHandle[i]; MSElementCP element = pEeh->GetElementCP ();
// point cloud handler - is unique Bentley::Ustn::Element::PointCloudHandler* handlerP = CastPointCloudHandler(pEeh);
// occur MicroStation error !!! g_handlerP ->SetClipBoundary(*pEeh, rPolygonFence);
// bool bVisable; int viewIndex = 1;
// change viewIndex, bVisable always false !!!! bVisable = g_handlerP ->GetViewDisplayState(*pEeh, viewIndex); }
return true;}
DreamTns.
dr.lee
g_handlerP (wrong) ----> handlerP
typing error:
g_handlerP ->SetClipBoundary(*pEeh, rPolygonFence); ==> handlerP ->SetClipBoundary(*pEeh, rPolygonFence);
bVisable = g_handlerP ->GetViewDisplayState(*pEeh, viewIndex); ==> bVisable = handlerP ->GetViewDisplayState(*pEeh, viewIndex);
Unknown said:std::vector<DPoint3d> g_rPickedPointsInPointCloudTool;
How do you build that list of DPoint3d?
Unknown said:bool CDreamBimPointCloudAPI::ClipInsidePointsOfPolyfonFence(std::vector<DPoint3d> rPolygonFence)
Passing an argument by value makes a local copy. If your vector is large that copy will be expensive. You can eliminate that possibility by passing by const reference …
ClipInsidePointsOfPolyfonFence (std::vector<DPoint3d> const& rPolygonFence)
The below is my test snippet. It can work for me. FYI
ElementID elID = 619; // Here elID is the element id of my PointCloud element ElementRef elRef = dgnCache_findElemByID (mdlModelRef_getCache(ACTIVEMODEL), elID); if (NULL == elRef) { mdlDialog_dmsgsPrint ("elRef == NULL"); return; } EditElemHandle elHandle (elRef, ACTIVEMODEL); if (!elHandle.IsValid ()) { mdlDialog_dmsgsPrint ("elHandle is invalid"); return; } DPoint3d origin = {5285240409.8599148, 1840374875.5143239, 460698}; DVec3d xVec, yVec, zVec; xVec.x = 2961.6924200057988; xVec.y = xVec.z = 0; yVec.y = -1879.2623732089996; yVec.x = yVec.z = 0; zVec.z = 8418; zVec.x = zVec.y = 0; OrientedBox box(xVec, yVec, zVec, origin); IPointCloudEdit* pPointCloudEdit = dynamic_cast<IPointCloudEdit*>(&elHandle.GetHandler ()); StatusInt status = pPointCloudEdit->SetClipBoundary (elHandle, box); if (SUCCESS == status) elHandle.ReplaceInModel();
Yongan.Fu. thanks for your kind support.
I have been implemented the SetClipBoundary (polygon and oriented box) functions successfuly by using IPointCloudEdit pointer and elHandle.ReplaceInModel().
dr.lee.