void SymmetryMod::SlicePolyObject (MNMesh & mesh, Point3 & N, float offset) { // Steve Anderson 9/14/2002 // Using the new "MN_MESH_TEMP_1" flag to override Slice selection behavior, // which is undesirable here. mesh.SetFlag (MN_MESH_TEMP_1); // Slice off everything below the plane: mesh.Slice (N, offset, MNEPS, false, true); mesh.ClearFlag (MN_MESH_TEMP_1); // Make sure we have a valid edge list: if (!mesh.GetFlag (MN_MESH_FILLED_IN)) mesh.FillInMesh(); // Mark the vertices on the plane boundary: mesh.ClearVFlags (MN_USER); for (int i=0; i<mesh.numv; i++) { if (mesh.v[i].GetFlag (MN_DEAD)) continue; float dist = DotProd (N, mesh.P(i)) - offset; if (fabsf(dist) > MNEPS) continue; mesh.v[i].SetFlag (MN_USER); } // Strip out faces on the mirror plane: (These aren't always removed by slice.) // Find the faces that use only mirror-plane vertices: mesh.ClearFFlags (MN_USER); mesh.PropegateComponentFlags (MNM_SL_FACE, MN_USER, MNM_SL_VERTEX, MN_USER, true); mesh.DeleteFlaggedFaces (MN_USER); // Clear out dead components: mesh.CollapseDeadStructs (); }
void SymmetryMod::WeldPolyObject (MNMesh & mesh, Point3 & N, float offset, float threshold) { // Mark the vertices within the welding threshold of the plane: mesh.ClearVFlags (MN_USER); for (int i=0; i<mesh.numv; i++) { if (mesh.v[i].GetFlag (MN_DEAD)) continue; float dist = DotProd (N, mesh.P(i)) - offset; if (fabsf(dist) > threshold) continue; mesh.v[i].SetFlag (MN_USER); } // Do the welding: if (mesh.WeldBorderVerts (threshold, MN_USER)) { // If result was true, we have some MN_DEAD components: mesh.CollapseDeadStructs (); } }
void PolyOpWeldVertex::Do(MNMesh & mesh) { // Weld the suitable border vertices: bool haveWelded = false; if (mesh.WeldBorderVerts (mThreshold, MN_USER)) { mesh.CollapseDeadStructs (); haveWelded = true; } // Weld vertices that share short edges: if (WeldShortPolyEdges (mesh, MN_USER)) haveWelded = true; if (haveWelded) { mesh.InvalidateTopoCache (); mesh.FillInMesh (); } }
void EditPolyData::ApplyAllOperations (MNMesh & mesh) { #ifdef __DEBUG_PRINT_EDIT_POLY DebugPrint (_T("EditPolyData::ApplyAllOperations\n")); #endif if (mpOpList) { // Preallocate if possible. (Upon first application, this will do nothing.) PolyOperationRecord* pOpRec = NULL; int newFaces(0), newVertices(0), newEdges(0); Tab<int> newMapVertices; newMapVertices.SetCount (mesh.numm + NUM_HIDDENMAPS); for (int mp=-NUM_HIDDENMAPS; mp<mesh.numm; mp++) newMapVertices[mp+NUM_HIDDENMAPS] = 0; for (pOpRec=mpOpList; pOpRec != NULL; pOpRec=pOpRec->Next()) { newFaces += pOpRec->Operation()->NewFaceCount(); newVertices += pOpRec->Operation()->NewVertexCount(); newEdges += pOpRec->Operation()->NewEdgeCount (); for (int mp=-NUM_HIDDENMAPS; mp<mesh.numm; mp++) { if (mesh.M(mp)->GetFlag (MN_DEAD)) continue; newMapVertices[mp+NUM_HIDDENMAPS] += pOpRec->Operation()->NewMapVertexCount(mp); } } mesh.VAlloc (mesh.numv + newVertices); mesh.EAlloc (mesh.nume + newEdges); mesh.FAlloc (mesh.numf + newFaces); for (int mp=-NUM_HIDDENMAPS; mp<mesh.numm; mp++) { MNMap *map = mesh.M(mp); if (map->GetFlag (MN_DEAD)) continue; map->VAlloc (map->numv + newMapVertices[mp+NUM_HIDDENMAPS]); map->FAlloc (map->numf + newFaces); } for (pOpRec=mpOpList; pOpRec != NULL; pOpRec=pOpRec->Next()) { #ifdef __DEBUG_PRINT_EDIT_POLY DebugPrint (_T("EditPolyData::Applying %s\n"), pOpRec->Operation()->Name()); #endif pOpRec->Operation()->SetUserFlags (mesh); bool ret = pOpRec->Operation()->Apply (mesh, pOpRec->LocalData()); if (ret && pOpRec->Operation()->CanDelete()) mesh.CollapseDeadStructs (); } } }