11/* ----------------------------------------------------------------------------*/
22#include " gmds/blocking/CurvedBlocking.h"
33/* ----------------------------------------------------------------------------*/
4+ #include < limits>
5+ /* ----------------------------------------------------------------------------*/
46using namespace gmds ;
57using namespace gmds ::blocking;
68/* ----------------------------------------------------------------------------*/
@@ -1000,7 +1002,7 @@ CurvedBlocking::capt_element(const int AnIdElement, const int ADim) {
10001002
10011003
10021004 if (ADim == 0 ){
1003- auto paramCut = get_cut_info (AnIdElement);
1005+ auto paramCut = get_cut_info (m_geom_model-> getPoint ( AnIdElement)-> point () );
10041006 cut_sheet (paramCut.first ,paramCut.second );
10051007 }
10061008 else {
@@ -1045,31 +1047,6 @@ CurvedBlocking::check_cut_possible(int pointId, std::vector<std::vector<CurvedBl
10451047
10461048}
10471049/* ----------------------------------------------------------------------------*/
1048-
1049- std::pair<CurvedBlocking::Edge, double >
1050- CurvedBlocking::get_cut_info (int pointId)
1051- {
1052- std::pair<CurvedBlocking::Edge,double > paramCut;
1053-
1054- // ============================================
1055- auto noCaptPoint0 = m_geom_model->getPoint (pointId);
1056- gmds::math::Point p (noCaptPoint0->X (),noCaptPoint0->Y (),noCaptPoint0->Z ());
1057-
1058- auto listEdgesPara = get_all_sheet_edge_sets ();
1059- std::vector<gmds::blocking::CurvedBlocking::Edge > listEdgesSplitable;
1060- unsigned int distMini = 1000 ;
1061- for (auto edges : listEdgesPara){
1062- auto projInfo = get_projection_info (p,edges);
1063- for (int i =0 ; i< projInfo.size ();i++){
1064- if (projInfo[i].second <1 && projInfo[i].second >0 && projInfo[i].first <distMini){
1065- paramCut.first = edges.at (i);
1066- paramCut.second = projInfo[i].second ;
1067- }
1068- }
1069- }
1070- return paramCut;
1071- }
1072- /* ----------------------------------------------------------------------------*/
10731050std::pair<CurvedBlocking::Edge, double >
10741051CurvedBlocking::get_cut_info (gmds::math::Point APoint)
10751052{
@@ -1081,19 +1058,17 @@ CurvedBlocking::get_cut_info(gmds::math::Point APoint)
10811058 // ============================================
10821059
10831060 auto listEdgesPara = get_all_sheet_edge_sets ();
1084- std::vector<gmds::blocking::CurvedBlocking::Edge > listEdgesSplitable;
1085- unsigned int distMini = 1000 ;
1061+ double distMini = std::numeric_limits<double >::max ();
10861062 for (auto edges : listEdgesPara){
10871063 auto projInfo = get_projection_info (APoint,edges);
10881064 for (int i =0 ; i< projInfo.size ();i++){
10891065 if (projInfo[i].second <1 && projInfo[i].second >0 && projInfo[i].first <distMini){
10901066 paramCut.first = edges.at (i);
10911067 paramCut.second = projInfo[i].second ;
1068+ distMini = projInfo[i].first ;
10921069 }
10931070 }
10941071 }
1095-
1096-
10971072 return paramCut;
10981073}
10991074
@@ -1231,8 +1206,16 @@ CurvedBlocking::get_projection_info(math::Point &AP, std::vector<CurvedBlocking:
12311206 std::vector<std::pair<double , double > > dist_coord;
12321207 for (auto e: AEdges) {
12331208 std::vector<Node> end_points = get_nodes_of_edge (e);
1234- math::Point end0 = end_points[0 ]->info ().point ;
1235- math::Point end1 = end_points[1 ]->info ().point ;
1209+ math::Point end0;
1210+ math::Point end1;
1211+ if ( end_points[0 ]->info ().topo_id < end_points[1 ]->info ().topo_id ) {
1212+ end0 = end_points[0 ]->info ().point ;
1213+ end1 = end_points[1 ]->info ().point ;
1214+ }
1215+ else {
1216+ end0 = end_points[1 ]->info ().point ;
1217+ end1 = end_points[0 ]->info ().point ;
1218+ }
12361219 math::Vector3d v1 = end1 - end0;
12371220 math::Vector3d v2 = AP - end0;
12381221 double coord = 0.0 ;
0 commit comments