-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cut off part feature of the mesh model #1512
Comments
Hello! First you need to use MeshLib/source/MRMesh/MRExtractIsolines.h Lines 22 to 23 in 0a4a1f3
It will return vector with plane sections, then you remove all sections that are not intersting for you (leaving only sections of Then call MeshLib/source/MRMesh/MRContoursCut.h Lines 101 to 107 in 0a4a1f3
with remained contours and MeshLib/source/MRMesh/MRContoursCut.h Lines 142 to 158 in 0a4a1f3
with the result It will give you MeshLib/source/MRMesh/MRContoursCut.h Lines 135 to 136 in 0a4a1f3
then you need to remove part that you dont need need: MeshLib/source/MRMesh/MRFillContour.h Lines 8 to 10 in 0a4a1f3
MeshLib/source/MRMesh/MRMeshTopology.h Lines 170 to 171 in 0a4a1f3
|
Hello,Can I set specified coordinates and normal vectors to determine the plane? if If I want to set the coordinate point as (1,1,0), the normal vector is (1,0,1),Can I directly set it? |
Hello! You should rotate and move the plane in this case: auto plane = MR::makePlane();
auto rotation = MR::Matrix3f::rotation( MR::Vector3f::plusZ(), MR::Vector3f( 1, 0, 1) );
plane.transform( MR::AffineXf3f::translation( MR::Vector3f( 1, 1, 0) ) * MR::AffineXf3f::linear( rotation ) ); |
Thanks a lot |
Hello! |
If the above small piece is what I want to delete, how should I do it? |
You don't need to make new auto plane11 = MR::Plane3f::fromDirAndPt(MR::Vector3f(0.5, 0.2, 0.6), MR::Vector3f(9, 0, 18));
auto plane22 = MR::Plane3f::fromDirAndPt(MR::Vector3f(0.142, -0.984, 0.104), MR::Vector3f(1, 0, 20));
auto plane33 = MR::Plane3f::fromDirAndPt(MR::Vector3f(0.5, -0.837, 0.071), MR::Vector3f(8, 4, 20));
auto planesection1 = MR::extractPlaneSections(*cylinder, plane11);
auto MeshContours1 = MR::convertSurfacePathsToMeshContours(*cylinder, planesection1);
MR::CutMeshResult result_plane_1 = MR::cutMesh(*cylinder, MeshContours1);
cylinder->topology.deleteFaces( MR::fillContourLeft(cylinder->topology, result_plane_1.resultCut) );
cylinder->invalidateCaches();
auto planesection2 = MR::extractPlaneSections(cylinder, plane22);
auto MeshContours2 = MR::convertSurfacePathsToMeshContours(cylinder, planesection2);
MR::CutMeshResult result_plane_2 = MR::cutMesh(cylinder, MeshContours2);
cylinder->topology.deleteFaces( cylinder->topology.flip( MR::fillContourLeft(cylinder->topology, result_plane_2.resultCut) ) );
cylinder->invalidateCaches();
auto planesection3 = MR::extractPlaneSections(cylinder, plane33);
auto MeshContours3 = MR::convertSurfacePathsToMeshContours(cylinder, planesection3);
MR::CutMeshResult result_plane_3 = MR::cutMesh(cylinder, MeshContours3);
cylinder->topology.deleteFaces( cylinder->topology.flip( MR::fillContourLeft(cylinder->topology, result_plane_3.resultCut) ) );
cylinder->invalidateCaches();
std::string filename_outerMesh_test_1 = "Mesh_result.stl";
MR::MeshSave::toBinaryStl(Mesh_result3, filename_outerMesh_test_1); |
Thanks a lot,There is a problem with the clip in the code that the author replied
code******************************** |
If I understand correctly you need to cut other part of mesh, to do it you need to |
Now I see, this can be done by like this: auto plane11 = MR::Plane3f::fromDirAndPt(MR::Vector3f(0.5, 0.2, 0.6), MR::Vector3f(9, 0, 18));
auto plane22 = MR::Plane3f::fromDirAndPt(MR::Vector3f(0.142, -0.984, 0.104), MR::Vector3f(1, 0, 20));
auto plane33 = MR::Plane3f::fromDirAndPt(MR::Vector3f(0.5, -0.837, 0.071), MR::Vector3f(8, 4, 20));
auto planesection1 = MR::extractPlaneSections(*cylinder, plane11);
auto MeshContours1 = MR::convertSurfacePathsToMeshContours(*cylinder, planesection1);
MR::CutMeshResult result_plane_1 = MR::cutMesh(*cylinder, MeshContours1);
auto leftFaces = cylinder->topology.flip( MR::fillContourLeft(cylinder->topology, result_plane_1.resultCut) );
MR::FaceMap new2OldMap2;
auto planesection2 = MR::extractPlaneSections(cylinder, plane22);
auto MeshContours2 = MR::convertSurfacePathsToMeshContours(cylinder, planesection2);
MR::FaceId oldFaceSize = cylinder->topology.lastValidFace() + 1;
MR::CutMeshResult result_plane_2 = MR::cutMesh(cylinder, MeshContours2, { .new2OldMap = new2OldMap2} );
for ( MR::FaceId f = oldFaceSize; f < MR::FaceId( int( cylinder->topology.faceSize() ) ); f++ )
{
if ( leftFaces.test( new2OldMap2[f] ) )
leftFaces.autoResizeSet( f );
}
leftFaces |= MR::fillContourLeft(cylinder->topology, result_plane_2.resultCut);
MR::FaceMap new2OldMap3;
auto planesection3 = MR::extractPlaneSections(cylinder, plane33);
auto MeshContours3 = MR::convertSurfacePathsToMeshContours(cylinder, planesection3);
oldFaceSize = cylinder->topology.lastValidFace() + 1;
MR::CutMeshResult result_plane_3 = MR::cutMesh(cylinder, MeshContours3, { .new2OldMap = new2OldMap3} );
for ( MR::FaceId f = oldFaceSize; f < MR::FaceId( int( cylinder->topology.faceSize() ) ); f++ )
{
if ( leftFaces.test( new2OldMap3[f] ) )
leftFaces.autoResizeSet( f );
}
leftFaces |= MR::fillContourLeft(cylinder->topology, result_plane_3.resultCut);
leftFaces &= cylinder->topology.getValidFaces();
cylinder->topology.deleteFaces( leftFaces );
cylinder->invalidateCaches(); |
Oh, sure you are right, does it fit your needs? |
Hello,If I use a plane to cut off a model, can I cut off some mesh features?For example, I want to cut off the A feature of the mesh model, but I don't want to cut off the B feature of the mesh model.
Is there any better way to solve this problem?
The text was updated successfully, but these errors were encountered: