74 _mesh->add_property(cut,
"Plane Cut Property" );
76 typename MeshT::FaceHandle fh ( _fh );
78 typename MeshT::FaceHandle current_face =
typename MeshT::FaceHandle(_fh);
80 for(
auto he_it : _mesh->halfedges())
81 _mesh->property( cut, he_it ) =
false;
85 bool nothingFound =
true;
86 int expansionLevel = 0;
87 bool flip_dir =
false;
90 std::vector< ACG::Vec3d > linePoints;
92 std::vector< typename MeshT::FaceHandle > startCandidates;
93 std::vector< typename MeshT::FaceHandle > expandable;
94 expandable.push_back( fh );
100 for (
typename MeshT::FaceHalfedgeIter fhe_it( *_mesh, current_face ); fhe_it.is_valid(); ++fhe_it){
101 if ( _mesh->property(cut,*fhe_it) )
105 typename MeshT::Point p1 = _mesh->point( _mesh->
to_vertex_handle(*fhe_it) );
107 typename MeshT::Point u = p1 - p0;
108 typename MeshT::Point w = p0 - _planePoint;
110 double D = (_planeNormal | u);
111 double N = - (_planeNormal | w);
115 if (sI < 0.0 || sI > 1.0 )
118 nothingFound =
false;
121 _mesh->property(cut,*fhe_it) =
true;
122 _mesh->property(cut,_mesh->opposite_halfedge_handle(*fhe_it)) =
true;
123 current_face = _mesh->face_handle(_mesh->opposite_halfedge_handle(*fhe_it));
125 if (!current_face.is_valid())
128 typename MeshT::Point cutPoint = p0 + sI * u;
132 linePoints.push_back(cutPoint);
134 linePoints.insert( linePoints.begin() , cutPoint );
143 if ( startCandidates.empty() ){
145 if (expansionLevel > 3 )
146 std::cerr <<
"Expanded" << expansionLevel <<
"rings but still nothing found!" << std::endl;
150 for (uint i=0; i < expandable.size(); i++)
151 for(
typename MeshT::FaceFaceIter ff_it(*_mesh, expandable[i]); ff_it.is_valid(); ++ff_it )
152 startCandidates.push_back( *ff_it );
159 if ( !startCandidates.empty() ){
160 fh = startCandidates.back();
161 expandable.push_back( fh );
162 startCandidates.pop_back();
166 }
else if (! flip_dir ){
175 _mesh->remove_property( cut );
193 typename MeshT::Scalar minDistance = FLT_MAX;
194 typename MeshT::EdgeHandle minEdge(-1);
196 for (
auto e_it : _mesh.edges()){
201 typename MeshT::Point p0 = _mesh.point( hh.
from() );
202 typename MeshT::Point p1 = _mesh.point( hh.
to() );
204 typename MeshT::Point u = p1 - p0;
205 typename MeshT::Point w = p0 - _planePoint;
207 double D = (_planeNormal | u);
208 double N = - (_planeNormal | w);
213 if (sI >= 0.0 && sI <= 1.0 ){
215 typename MeshT::Point cutPoint = p0 + sI * u;
217 typename MeshT::Scalar dist = (cutPoint - _planePoint).sqrnorm();
219 if ( dist < minDistance ){
std::vector< ACG::Vec3d > getIntersectionPoints(MeshT *_mesh, uint _fh, ACG::Vec3d _planeNormal, ACG::Vec3d _planePoint, bool &_closed)
get the points from the intersection between mesh and plane