how to use convertMeshTriPointsToClosedContour? #4073
Answered
by
Fedr
Gihong-Yim
asked this question in
Q&A
-
bool VxMeshLibCutMesh(SVXModuleParameters* pstModuleParameter)
{
CVXLObject* pCLObject = (CVXLObject*)pstModuleParameter->GetVXObject(vxrObjectTypeCUSTOMLIST, true, 0);
vector<vxdouble3>* pvtrInputPoints = new vector<vxdouble3>();
pCLObject->GetList(L"_vlist_DOUBLE3_CutPoints", (void**)&pvtrInputPoints);
CVXVObjectPrimitive* pCMeshIn = (CVXVObjectPrimitive*)pstModuleParameter->GetVXObject(vxrObjectTypePRIMITIVE, true, 0);
CVXVObjectPrimitive* pCMeshOut0 = (CVXVObjectPrimitive*)pstModuleParameter->GetVXObject(vxrObjectTypePRIMITIVE, true, 1);
CVXVObjectPrimitive* pCMeshOut1 = (CVXVObjectPrimitive*)pstModuleParameter->GetVXObject(vxrObjectTypePRIMITIVE, true, 2);
Mesh meshOrg = makeCube();
VxConvertVxToMRMesh(pCMeshIn, meshOrg);
meshOrg.packOptimally();
vector<MeshTriPoint> cutPoints;
for (size_t i = 0; i < pvtrInputPoints->size(); i++)
{
double dDistance = 100000.0f;
VertId vIDtemp;
for (int j = 0; j < meshOrg.points.size(); j++)
{
Vector3f vertPos = meshOrg.points.data()[j];
double dCurDistance = VxVector3fDistance(Vector3f(pvtrInputPoints->at(i).x, pvtrInputPoints->at(i).y, pvtrInputPoints->at(i).z), vertPos);
if (dCurDistance < dDistance)
{
dDistance = dCurDistance;
vIDtemp = VertId(j);
}
}
cutPoints.push_back(MeshTriPoint(meshOrg.topology, vIDtemp));
}
auto result = convertMeshTriPointsToClosedContour(meshOrg, cutPoints, MR::SearchPathSettings({ MR::GeodesicPathApprox::DijkstraAStar, 100 }));
if (result.has_value())
{
vector<OneMeshContour> contours;
contours.push_back(move(result.value()));
auto resultCut = cutMesh(meshOrg, contours).resultCut;
auto mesh0 = fillContourLeft(meshOrg.topology, resultCut);
auto mesh1 = meshOrg.topology.getValidFaces() - mesh0;
Mesh resultMesh0 = Mesh();
resultMesh0.addPartByMask(meshOrg, mesh0);
Mesh resultMesh1 = Mesh();
resultMesh1.addPartByMask(meshOrg, mesh1);
VxConvertMRMeshToVx(resultMesh0, pCMeshOut0);
VxConvertMRMeshToVx(resultMesh1, pCMeshOut1);
return true;
}
return false;
}
| |
Beta Was this translation helpful? Give feedback.
Answered by
Fedr
Feb 7, 2025
Replies: 1 comment
-
The function
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Fedr
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The function
convertMeshTriPointsToClosedContour
returnsExpected<OneMeshContour>
type, which has 3 main methodshas_value()
,value()
,error()
:has_value()
returnstrue
on function's success andfalse
otherwise,value()
can be called only ifhas_value()==true
,has_value()==false
, please callerror()
method, which will return you a string with the description of what went wrong.