Skip to content

Commit

Permalink
moved {edge,vert}_is_visible to abstract_mesh. restricted picking of …
Browse files Browse the repository at this point in the history
…those elements to visible stuff only
mlivesu committed Nov 19, 2023
1 parent a9b6a79 commit b041130
Showing 4 changed files with 45 additions and 19 deletions.
45 changes: 43 additions & 2 deletions include/cinolib/meshes/abstract_mesh.cpp
Original file line number Diff line number Diff line change
@@ -954,6 +954,38 @@ void AbstractMesh<M,V,E,P>::edge_set_alpha(const float alpha)

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

template<class M, class V, class E, class P>
CINO_INLINE
bool AbstractMesh<M,V,E,P>::vert_is_visible(const uint vid) const
{
for(uint pid : this->adj_v2p(vid))
{
if(!this->poly_data(pid).flags[HIDDEN])
{
return true;
}
}
return false;
}

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

template<class M, class V, class E, class P>
CINO_INLINE
bool AbstractMesh<M,V,E,P>::edge_is_visible(const uint eid) const
{
for(uint pid : this->adj_e2p(eid))
{
if(!this->poly_data(pid).flags[HIDDEN])
{
return true;
}
}
return false;
}

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

template<class M, class V, class E, class P>
CINO_INLINE
uint AbstractMesh<M,V,E,P>::poly_vert_id(const uint pid, const uint offset) const
@@ -1373,7 +1405,11 @@ CINO_INLINE
uint AbstractMesh<M,V,E,P>::pick_vert(const vec3d & p) const
{
std::vector<std::pair<double,uint>> closest;
for(uint vid=0; vid<this->num_verts(); ++vid) closest.push_back(std::make_pair(this->vert(vid).dist(p),vid));
for(uint vid=0; vid<this->num_verts(); ++vid)
{
if(vert_is_visible(vid)) closest.push_back(std::make_pair(this->vert(vid).dist(p),vid));
}
if(closest.empty()) return 0;
std::sort(closest.begin(), closest.end());
return closest.front().second;
}
@@ -1385,7 +1421,11 @@ CINO_INLINE
uint AbstractMesh<M,V,E,P>::pick_edge(const vec3d & p) const
{
std::vector<std::pair<double,uint>> closest;
for(uint eid=0; eid<this->num_edges(); ++eid) closest.push_back(std::make_pair(this->edge_sample_at(eid, 0.5).dist(p),eid));
for(uint eid=0; eid<this->num_edges(); ++eid)
{
if(edge_is_visible(eid)) closest.push_back(std::make_pair(this->edge_sample_at(eid, 0.5).dist(p),eid));
}
if(closest.empty()) return 0;
std::sort(closest.begin(), closest.end());
return closest.front().second;
}
@@ -1401,6 +1441,7 @@ uint AbstractMesh<M,V,E,P>::pick_poly(const vec3d & p) const
{
if(!this->poly_data(pid).flags[HIDDEN]) closest.push_back(std::make_pair(this->poly_centroid(pid).dist(p),pid));
}
if(closest.empty()) return 0;
std::sort(closest.begin(), closest.end());
return closest.front().second;
}
2 changes: 2 additions & 0 deletions include/cinolib/meshes/abstract_mesh.h
Original file line number Diff line number Diff line change
@@ -237,6 +237,7 @@ class AbstractMesh
virtual bool vert_is_manifold (const uint vid) const = 0;
void vert_set_flag (const int flag, const bool b);
void vert_set_flag (const int flag, const bool b, const std::vector<uint> & vids);
bool vert_is_visible (const uint vid) const;

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@@ -266,6 +267,7 @@ class AbstractMesh
void edge_set_flag (const int flag, const bool b);
void edge_set_flag (const int flag, const bool b, const std::vector<uint> & eids);
virtual double edge_weight (const uint eid, const int type) const;
bool edge_is_visible (const uint eid) const;

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

16 changes: 0 additions & 16 deletions include/cinolib/meshes/abstract_polyhedralmesh.cpp
Original file line number Diff line number Diff line change
@@ -576,22 +576,6 @@ bool AbstractPolyhedralMesh<M,V,E,F,P>::face_is_visible(const uint fid, uint & p

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

template<class M, class V, class E, class F, class P>
CINO_INLINE
bool AbstractPolyhedralMesh<M,V,E,F,P>::edge_is_visible(const uint eid) const
{
for(uint pid : this->adj_e2p(eid))
{
if(!this->poly_data(pid).flags[HIDDEN])
{
return true;
}
}
return false;
}

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

template<class M, class V, class E, class F, class P>
CINO_INLINE
void AbstractPolyhedralMesh<M,V,E,F,P>::face_apply_labels(const std::vector<int> & labels)
1 change: 0 additions & 1 deletion include/cinolib/meshes/abstract_polyhedralmesh.h
Original file line number Diff line number Diff line change
@@ -219,7 +219,6 @@ class AbstractPolyhedralMesh : public AbstractMesh<M,V,E,P>
std::vector<uint> edge_faces_link (const uint eid) const;
uint edge_split (const uint eid, const vec3d & p);
double edge_dihedral_angle (const uint eid) const override;
bool edge_is_visible (const uint eid) const;

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

0 comments on commit b041130

Please sign in to comment.