Skip to content

Commit

Permalink
Backup work on snapping with successive point snap/not snap
Browse files Browse the repository at this point in the history
  • Loading branch information
epernod committed Jan 6, 2025
1 parent e007288 commit dd3682c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<FixedProjectiveConstraint template="Vec3d" name="fixedConstraint1" indices="@box_roi1.indices"/>
<TriangularFEMForceField template="Vec3d" name="FEM" method="large" poissonRatio="0.45" youngModulus="600" />
<TriangleCollisionModel name="default7" selfCollision="true" />
<TriangleCuttingController name="TriCtrl" triAID="33" triBID="107" drawDebugCut="0" performCut="1"/>
<TriangleCuttingController name="TriCtrl" triAID="33" triBID="4" drawDebugCut="1" performCut="1"/>
<Node name="visu">
<OglModel name="Visual" texcoords="@../loader.texcoords" texturename="textures/colorMap.png"/>
<IdentityMapping input="@.." output="@." />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-0.740008 44.5146 -4.62505
-0.707107 6.93889e-18 1.14281e-17 0.707107
26 changes: 24 additions & 2 deletions src/Tearing/Controllers/TriangleCuttingController.inl
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,32 @@ void TriangleCuttingController<DataTypes>::processCut()
std::vector<std::shared_ptr<PointToAdd> >& PTAs = PTA_map[triIds[i]];
PTAs.push_back(PTA);
}

std::set <Topology::PointID> psnap;
for (unsigned int i = 0; i < edges_list.size(); ++i)
{
const Topology::Edge& edge = edges[edges_list[i]];
if (coords_list[i] > snapThreshold)
psnap.insert(edge[0]);
else if (1.0 - coords_list[i] > snapThreshold)
psnap.insert(edge[1]);
}
std::cout << "psnap: " << psnap << std::endl;

// create PointToAdd from edges
for (unsigned int i = 0; i < edges_list.size(); ++i)
{
const Topology::Edge& edge = edges[edges_list[i]];
if (psnap.find(edge[0]) != psnap.end())
coords_list[i] = 1.0;
else if (psnap.find(edge[1]) != psnap.end())
coords_list[i] = 0.0;
}

// create PointToAdd from edges
for (unsigned int i = 0; i < edges_list.size(); ++i)
{
const Topology::Edge& edge = edges[edges_list[i]];
std::cout << "Edge: " << edges_list[i] << " | " << edge << " | " << coords_list[i] << std::endl;
type::vector<SReal> _coefs = { coords_list[i], 1.0 - coords_list[i] };
type::vector<Topology::PointID> _ancestors = { edge[0], edge[1] };

Expand All @@ -516,18 +536,20 @@ void TriangleCuttingController<DataTypes>::processCut()
auto itM = cloneMap.find(PTA->m_idPoint);
if (itM == cloneMap.end())
{
std::cout << "Edge: " << edges_list[i] << " snap PTA: " << nbrPoints << std::endl;
std::cout << "snap2: " << PTA->m_idPoint << " -> " << PTA->m_idClone << std::endl;
cloneMap[PTA->m_idPoint] = PTA->m_idClone;
m_pointsToAdd.push_back(PTA);
nbrPoints++;
}
else {
std::cout << " pass snap: " << nbrPoints << std::endl;
std::cout << "Edge: " << edges_list[i] << " pass snap: " << PTA->m_idPoint << " -> " << PTA->m_idClone << std::endl;
PTA = m_pointsToAdd.back();
}
}
else
{
std::cout << "Edge: " << edges_list[i] << " Add PTA: " << nbrPoints << std::endl;
m_pointsToAdd.push_back(PTA);
nbrPoints = nbrPoints +2;
}
Expand Down

0 comments on commit dd3682c

Please sign in to comment.