Comments (16)
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 ) );
from meshlib.
If I understand correctly you need to cut other part of mesh, to do it you need to flip
bitsets before delete operation:
in current code version I suggest flip
facebitset1
and facebitset2
and not flipping MR::fillContourLeft(cylinder->topology, result_plane_1.resultCut)
. So you can try not to flip them.
from meshlib.
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();
from meshlib.
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 A
).
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
note that it is not always possible, for example in torus mesh there will not be determined left or right part
from meshlib.
Hello,Can I set specified coordinates and normal vectors to determine the plane?
code******
auto plane = MR::makePlane();
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?
from meshlib.
Thanks a lot
from meshlib.
Hello,I found that there is only one cut function in the software, will more cutting functions be added in the future?I need to remove the facets in the positive direction of multiple facets
from meshlib.
Hello!
You can cut it three times one by one. We are not planning to add several cuts at the same time.
from meshlib.
Thanks a lot.Now it is possible to find a section through three cuts,But I want to get the other half, how should I get better?
code*********
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);
MR::Mesh Mesh_result1;
MR::reverse(result_plane_1.resultCut);
auto outerBitSet_plane_1 = MR::fillContourLeft(cylinder->topology, result_plane_1.resultCut);
Mesh_result1.addPartByMask(*cylinder, outerBitSet_plane_1);
auto planesection2 = MR::extractPlaneSections(Mesh_result1, plane22);
auto MeshContours2 = MR::convertSurfacePathsToMeshContours(Mesh_result1, planesection2);
MR::CutMeshResult result_plane_2 = MR::cutMesh(Mesh_result1, MeshContours2);
MR::Mesh Mesh_result2;
auto outerBitSet_plane_2 = MR::fillContourLeft(Mesh_result1.topology, result_plane_2.resultCut);
Mesh_result2.addPartByMask(Mesh_result1, outerBitSet_plane_2);
auto planesection3 = MR::extractPlaneSections(Mesh_result2, plane33);
auto MeshContours3 = MR::convertSurfacePathsToMeshContours(Mesh_result2, planesection3);
MR::CutMeshResult result_plane_3 = MR::cutMesh(Mesh_result2, MeshContours3);
MR::Mesh Mesh_result3;
auto outerBitSet_plane_3 = MR::fillContourLeft(Mesh_result2.topology, result_plane_3.resultCut);
Mesh_result3.addPartByMask(Mesh_result2, outerBitSet_plane_3);
std::string filename_outerMesh_test_1 = "Mesh_result.stl";
MR::MeshSave::toBinaryStl(Mesh_result3, filename_outerMesh_test_1);
from meshlib.
If the above small piece is what I want to delete, how should I do it?
from meshlib.
You don't need to make new Mesh
each time:
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);
from meshlib.
Thanks a lot,There is a problem with the clip in the code that the author replied
code************************
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);
auto facebitset1 = MR::fillContourLeft(cylinder->topology, result_plane_2.resultCut);
cylinder->topology.flip(facebitset1);
cylinder->topology.deleteFaces(facebitset1);
cylinder->invalidateCaches();
auto planesection3 = MR::extractPlaneSections(*cylinder, plane33);
auto MeshContours3 = MR::convertSurfacePathsToMeshContours(*cylinder, planesection3);
MR::CutMeshResult result_plane_3 = MR::cutMesh(*cylinder, MeshContours3);
auto facebitset2 = MR::fillContourLeft(cylinder->topology, result_plane_3.resultCut);
cylinder->topology.flip(facebitset2);
cylinder->topology.deleteFaces(facebitset2);
cylinder->invalidateCaches();
code********************************
Now I want to delete the model, that is, output the model without this part, how should I do it better?
from meshlib.
Thanks a lot.In fact, there is some doubt:
If I import a cylinder model,The blue part is what I want and the white part is what I want to remove
If I cut three times it is easy to get the white part.But if I cut three times it's easy to cut the rest of the blue.
How should I get the blue part of the mesh without changing the mesh model too much?
from meshlib.
Thanks a lot for reply.
The code needs to be modified slightly
leftFaces &= MR::fillContourLeft(cylinder->topology, result_plane_2.resultCut);
leftFaces &= MR::fillContourLeft(cylinder->topology, result_plane_3.resultCut);
Then the relevant mesh can be obtained
from meshlib.
Oh, sure you are right, does it fit your needs?
from meshlib.
Thanks a lot.It would be even better if it can be improved.
In fact, there is another detail
If I cut three times, then the other local area meshes will also be cut
for example:
It would be better if these can be avoided
from meshlib.
Related Issues (20)
- Expose RelaxKeepVolume HOT 5
- VSCode Autocompletion of `.so` files HOT 6
- line self-intersection HOT 2
- Local setup HOT 5
- Error while showing numpad keys in F1 menu
- Negative offsetting in offsetMesh HOT 1
- Negative offset in thickenMesh results in incorrect filling of mesh HOT 3
- Readme installation steps are incorrect for Linux HOT 4
- Installation on Linux when sudo privileges are not available HOT 1
- Python Meshlib DistanceMap Interpolation Issue HOT 2
- meshlib.mrmeshpy.uniteCloseVertices does not exist in Python HOT 4
- Plane cut HOT 2
- Minkowski Sum in python HOT 2
- Problems in refine in cylinder mesh HOT 1
- add possibility to support rectangular planes
- setup z scale as ( ScaleX + ScaleY ) / 2 for plane feature HOT 1
- Creating grid meshes based on arbitrary shape input HOT 29
- Create a 3D Mesh from a list of vertices and faces. HOT 3
- Hole & Boundary edge length in Python HOT 5
- The Angle between two vectors is 0 to pi, why not 0-2pi HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meshlib.