i am trying to find an idea:
i have for example two cubes, both share some triangles wich are on the same positions (i dont know which,and i dont know how many) but both share a bit of surface
like these ones highlighted here:

is there any way to find these doubled faces when they share some area? and then any way to delete them?

any idea would be great!

EDIT:

i realized, that i can also happen, that there is one fine mesh, and one rough. in this scenario i would find the faces wich are fully included by the rough one like these here:

yes i tried it, and it does something but not what i need (i think ). i am not quite sure what âadjacentâ means. (from the Documentation: Force adjacent facets to share vertices and remove any facets that have all vertices in a line)

to be honest, i have no idea what really happens here: this is the original test mesh:

Each face of the box is made up of two adjacent facet triangles each facet has 3 vertices.
Facets are adjacent if they share an edge.

In each box there are 12 facets.

Let facet 0 and facet 1 be the adjacent facets on the front face

In the bottom box we label the vertices of facet 0, - 0, 1, 2, for facet 1, - 3, 4, 5 and so on, each facet having uniquely vertex indices.

In the top box we label the corners of the box from 0 to 7 and use this numbering to label the vertices of each facet. So that the vertices of facet 0, - 0, 1, 2, for facet 2 - 0, 2 , 3.

âforceSharedVerticesâ converts the bottom box vertexData to that of the top box.
âconvertToFlatShadedMeshâ converts the top box vertexData to that of the bottom box

If facets are not truely adjacent these will not work. Looking at your image the facet triangles of your boxes are not truely adjacent, ie they do not fully share edges.

IMHO I wonder if the work involved in removing double faces in your case (it would be quite complicated) is worth the small gain your might make.

Hi, thank you so much for your explanation! i think i understand now what it does. Yes - these faces were created by âextrudingâ the mesh from a polyline - and each mesh has its own polyline. probably the start/ endpoints are not 100% the same because of rounding issues.
The goal is actually not optimizing the mesh in terms of reducing faces - the goal is to have one âhullâ mesh (they represent building hulls and are supposed to be used for some simulations). So i really cannot have these âinsideâ mesh faces.

I will now try to somehow filter the points out programmatically.

If you have any other idea - just let me know.
Thank you so much for your help!

Will the extruded meshes you are fitting together always be box shaped? If so you might be better off constructing the boxes from planes with smaller planes on the side where it fits with another.

i just had an ideaâŚ
even it would be very expensive - but wouldnt it be possible to somehow shoot a ray from each triangle in both normal and negative normal direction and then check if the ray hits something in a very short distance (so i could also take unprecise meshes into account) - and then if so delete the triangle where the ray was comming from.
the mesh i want to delete the faces from is now a custom mesh.
is that possible? Does that makes sense?

maybe that makes it a little bit more understandable:

Hi,
i am working on this problem again - i have made a filter function wich works like the idea i had above.
(i have a contextmesh, and my own mesh. from my own mesh i shoot a ray from each face to check if it hits something. and then if so i remove it form the array of facesâŚ)

it works as expected, but is too slow for my liking. do you have any idea how to speed that up? especially this consumes a lot of time:

const rayIn = Ray.Transform(
new Ray(position, normal, distance),
matrix
);
const rayOut = Ray.Transform(
new Ray(position, normal.negate(), distance),
matrix
);
let collision = rayIn.intersectsMesh(contextMesh[0]).hit;
if (!collision) {
rayOut.intersectsMesh(contextMesh[0]).hit
? (collision = true)
: (collision = false);
}
if (!collision) {
for (let index = 0; index < 4; index++) {
filteredMeshPoints.push(meshPoints[meshPointsindex + index]);
}
for (let index = 0; index < 18; index++) {
filteredMeshPositions.push(
meshPositions[(meshPointsindex / 4) * 6 * 3 + index]
);
}
}

that takes around 0.5ms wich is quite some time when doing this for around 30.000 faces.
What can i do here?

Hi, i did look into it, but did not get the results i was looking for.
i am now using https://rapier.rs/ just for the rays and it is blazingly fast! (somewhere between 10-100 times faster).