Comments (4)
Hello!
Could you please provide meshes so we can reproduce the issue on our end?
from meshlib.
Sure thing. Please see the example below:
from meshlib import mrmeshpy as mm
from meshlib import mrmeshnumpy as mn
def get_inside(mesh_a, mesh_b):
bOperation = mm.BooleanOperation.InsideA
bResMapper = mm.BooleanResultMapper()
bResult = mm.boolean(mesh_a, mesh_b, bOperation, None, bResMapper)
inner_faces = bResMapper.map(mesh_a.topology.getValidFaces(), mm.BooleanResMapObj.A)
inner_verts = bResMapper.map(mesh_a.topology.getValidVerts(), mm.BooleanResMapObj.A)
return mn.getNumpyBitSet(inner_faces), mn.getNumpyBitSet(inner_verts)
torusIntersected = mm.makeTorusWithSelfIntersections(2, 1, 10, 10, None)
mm.fixSelfIntersections(torusIntersected, 0.1)
torus = mm.makeTorus(2, 1, 10, 10, None)
transVector = mm.Vector3f()
transVector.x = 0.5
transVector.y = 1
transVector.z = 1
diffXf = mm.AffineXf3f.translation(transVector)
torus2 = mm.makeTorus(2, 1, 10, 10, None)
torus2.transform(diffXf)
print(f"Valid faces: {torus.topology.getValidFaces().size()}")
print(f"Valid verts: {torus.topology.getValidVerts().size()}")
inside_faces, inside_verts = get_inside(mesh_a=torus, mesh_b=torus2)
print(f"Inside faces: {inside_faces.size}")
print(f"Inside verts: {inside_verts.size}")
print(inside_faces)
print(inside_verts)
Which outputs the following:
Valid faces: 200
Valid verts: 100
Inside faces: 154
Inside verts: 25
[ True True True True True True True True True True True True
True True True True True True True True True True True True
True True True True True True True True True True True True
True True True True True True True True True True True True
True True True True True True True True True True True True
True True True True True True True True True True True True
True True True True True True True True True True True True
True True True True True True True True True True True True
True True True True True True True True True True True True
True True True True True True True True True True True True
True True True True True True True True True True True True
True True True True True True True True True True True True
True True True True True True True True True True]
[ True True True True True True True True True True True True
True True True True True True True True True True True True
True]
What I'd expected was the that the outputted bitsets would be the same length as that of getValidFaces
and getValidVerts
but with boolean values indicating if face or vertices comply with the boolean operation.
from meshlib.
Thanks!
Now I understand the problem, really BooleanResultMapper.map
functions return BitSets of result mesh that correspond to given BitSet. As I understand you need to filter torus.topology.getValidFaces()
There are maps
that allow to do it in c++
auto validFaces = torus.topology.getValidFaces();
const auto& cut2originMap = mapper.maps[int(BooleanResultMapper::MapObject::A)].cut2origin;
const auto& cut2newMap = mapper.maps[int(BooleanResultMapper::MapObject::A)].cut2newFaces;
for ( int i = 0; i < cut2originMap.size(); ++i )
{
auto orgFace = cut2originMap[FaceId(i)];
if ( !orgFace.valid() )
continue;
if ( !cut2newMap[FaceId(i)].valid() )
validFaces.reset( orgFace );
}
Unfortunately these maps are not exposed to python yet, we will expose them, an maybe add special functions in Mapper class.
For now there is workaround
def get_inside(mesh_a, mesh_b):
bOperation = mm.BooleanOperation.InsideA
bResMapper = mm.BooleanResultMapper()
bResult = mm.boolean(mesh_a, mesh_b, bOperation, None, bResMapper)
inner_faces = mesh_a.topology.getValidFaces()
for f in inner_faces:
bs = mm.FaceBitSet()
bs.resize( f.get()+1)
bs.set(f)
if (bResMapper.map(bs, mm.BooleanResMapObj.A).count() == 0):
inner_faces.set(f,False)
inner_verts = mesh_a.topology.getValidVerts()
for v in inner_verts:
bs = mm.VertBitSet()
bs.resize( v.get()+1)
bs.set(v)
if (bResMapper.map(bs, mm.BooleanResMapObj.A).count() == 0):
inner_verts.set(v,False)
return mn.getNumpyBitSet(inner_faces), mn.getNumpyBitSet(inner_verts)
surely it will do a lot of excessive computations, but it is easiest way to implement it right now
from meshlib.
Got it! Indeed see where this is coming from now!
from meshlib.
Related Issues (20)
- Are there any examples of emscripten for reference? HOT 1
- WSL Ubuntu 22 build issue: Target "MRCuda" requires the language dialect "CUDA20" HOT 1
- Issue with `vectorEdges` in Python (Windows) HOT 4
- Expose computePerFaceNormals results to numpy HOT 2
- SegmentByGraphCut not Modifying faceBitSet HOT 3
- Correct Method for Projecting Face Labels of a Mesh with MeshToDistanceVolume HOT 2
- EditableProject Template for External Plugins HOT 5
- Add overload to find closest intersections for computeSkyViewFactor HOT 5
- Anisotropic offsetting HOT 5
- Reproduce Fill Hole & Smooth in python HOT 1
- mrmeshpy.decimateMesh question HOT 3
- Installation via package manager using pip-24.0 & python 3.12.1 not successfull HOT 12
- pointcloud sampling HOT 4
- type object 'meshlib.mrmeshpy.LaplacianEdgeWeightsParam' has no attribute 'CotanWithAreaEqWeight' HOT 1
- Meshlib WASM Web Execution HOT 2
- VectorFloatByVert to numpy HOT 1
- Show notification unshadowed if running progress dialog
- Compilation Error in MRPch Project with Eigen3 HOT 4
- Chinese support problem HOT 1
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.