How can the two IDs of the same face be matched?

The main issue with Hoops Communicator now is that it is concentrated on a single point. For example, if a user has a cube named partA, with six faces each having its own ID, when converting it to a sc.file, the cube’s name remains partA. However, the IDs of the six faces should be assigned by the SC library or HWV itself. How can the two IDs of the same face be matched? The same issue applies to points/lines.

Hello,

It’s not clear what you mean by:

six faces each having its own ID

Are you referring to metadata in the mesh geometry itself? If you have a CAD file to test, that would be helpful. If the file is not too big, you can send to me via a direct message (by clicking my profile name). Also please share any code snippet that you using.

Thanks,
Tino

Hello,Tino!
Thanks for your reply!

For example, i created a cube in my software. I managed the IDs of Point or Line or Face in my software. Then, i upload the cube to the webpage by SC File and show in the Hoops webViewer(hwv), the IDs of Point or Line or Face is managed by the hwv system. How can i match the id in the hwv with my software one by one?
Thanks a lot!

Best!

Jenson

The ID for a face is the index in the vector container for the Mesh.face_elements when the face was created. In the Web Viewer, the face index can be retrieved using the function FaceEntity.getCadFaceIndex. More information on the face element through the MeshData object.

As an example, below is Javascript code with gets the face index from a selection and then retrieves specific point information for the face:

hwv.setCallbacks({
    selectionArray: async function (selections) {
        if (selections.length > 0) {
            for (const selectionEvent of selections) {
                var selection = selectionEvent.getSelection();
                var nodeid = selection.getNodeId();
				console.log("Selected Node: " + nodeid);
				
				if (selection.getFaceEntity() != null) {
					let faceIndex = selection.getFaceEntity().getCadFaceIndex();
					console.log("Face ID: " + faceIndex);
					
					let data = await hwv.model.getNodeMeshData(nodeid);
					let face = data.faces.element(faceIndex);
					let pp = face.iterate();

					console.log("face elements: " + JSON.stringify(face));
						
					for (let j = 0; j < face.vertexCount; j++) {           
						let rawpoint = pp.next();
						console.log("points array: " + JSON.stringify(rawpoint));
					}
				}
            }
        }
    },
})

Hello,Tino:

Thanks a lot for your guidance! You’re truly a sage!

1 Like