Skip to content

Commit a53a0c8

Browse files
Add an operation to get a curved blocking edge from its two end points (#368)
Make the cut sheet consistent about edge orientation. Warning: some tests must be fixed (Paul'Phd work)
1 parent 8527a7b commit a53a0c8

File tree

3 files changed

+88
-12
lines changed

3 files changed

+88
-12
lines changed

blocking/inc/gmds/blocking/CurvedBlocking.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,22 @@ class LIB_GMDS_BLOCKING_API CurvedBlocking
430430
* @param ALoc the new node location
431431
*/
432432
void move_node(Node AN, math::Point &ALoc);
433+
434+
/** Returns the edge that connects nodes of ids @p AN1 and @p AN2
435+
*
436+
* @param AN1 a first node id
437+
* @param AN2 a second node id
438+
* @return the edge connecting @p AN1 and @p AN2
439+
*/
440+
CurvedBlocking::Edge get_edge(const int AN1, const int AN2);
441+
/** Returns the edge that connects nodes @p AN1 and @p AN2
442+
*
443+
* @param AN1 a first node
444+
* @param AN2 a second node
445+
* @return the edge connecting @p AN1 and @p AN2
446+
*/
447+
CurvedBlocking::Edge get_edge(const CurvedBlocking::Node AN1, const CurvedBlocking::Node AN2);
448+
433449
/** Get all the edges adjacent to a node
434450
* @param[in] AN a node
435451
* @return the set of edges adjacent to the node.
@@ -554,7 +570,8 @@ class LIB_GMDS_BLOCKING_API CurvedBlocking
554570
*/
555571
void cut_sheet(const Edge AE, const math::Point &AP);
556572
/**@brief Split the sheet defined by edge @p AE at the parameter @p AParam, which is included
557-
* in ]0,1[. The first end point of @p AE is at parameter 0, the second one at parameter 1.
573+
* in ]0,1[. The end point of @p AE with the lowest id is at parameter 0,
574+
* the second one at parameter 1.
558575
*
559576
* @param[in] AE an edge we want to split in two edges
560577
* @param[in] AParam a parameter included in ]0,1[

blocking/src/CurvedBlocking.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,26 @@ CurvedBlocking::get_blocks_of_face(const Face AF) {
253253
}
254254
return blocks;
255255
}
256-
256+
/*----------------------------------------------------------------------------*/
257+
CurvedBlocking::Edge CurvedBlocking::get_edge(const CurvedBlocking::Node AN1, const CurvedBlocking::Node AN2)
258+
{
259+
return get_edge(AN1->info().topo_id,AN2->info().topo_id);
260+
}
261+
/*----------------------------------------------------------------------------*/
262+
CurvedBlocking::Edge CurvedBlocking::get_edge(const int AN1, const int AN2)
263+
{
264+
auto edges = get_all_edges();
265+
for(auto e: edges){
266+
auto nodes_of_e = get_nodes_of_edge(e);
267+
if( nodes_of_e[0]->info().topo_id == AN1 &&
268+
nodes_of_e[1]->info().topo_id == AN2)
269+
return e;
270+
else if( nodes_of_e[0]->info().topo_id == AN2 &&
271+
nodes_of_e[1]->info().topo_id == AN1)
272+
return e;
273+
}
274+
throw GMDSException("No edge with given end points");
275+
}
257276
/*----------------------------------------------------------------------------*/
258277
std::vector<CurvedBlocking::Edge>
259278
CurvedBlocking::get_all_edges() {
@@ -825,9 +844,15 @@ CurvedBlocking::get_all_sheet_darts(const Edge AE, std::vector<Dart3> &ADarts) {
825844
auto edge_mark = m_gmap.get_new_mark();
826845

827846
std::vector<Dart3> front;
828-
front.push_back(AE->dart());
847+
// For all the sheet operations, we orient the edges using its end point ids (from the lowest to the highest).
848+
// We order that here!!
849+
auto first_dart = AE->dart();
850+
if(m_gmap.attribute<0>(first_dart)->info().topo_id>m_gmap.attribute<0>(m_gmap.alpha<0>(first_dart))->info().topo_id)
851+
first_dart = m_gmap.alpha<0>(first_dart);
852+
853+
front.push_back(first_dart);
829854
// the current dart belongs to the final set of darts
830-
ADarts.push_back(AE->dart());
855+
ADarts.push_back(first_dart);
831856
// we mark all the dart of the inital edge to avoid to traverse it twice
832857
m_gmap.mark_cell<1>(AE->dart(), edge_mark);
833858

blocking/tst/CurvedBlockingTestSuite.h

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ TEST(CurvedBlockingTestSuite, global_cell_accessors)
129129
ASSERT_EQ(11, bl.get_all_faces().size());
130130
ASSERT_EQ(2, bl.get_all_blocks().size());
131131
}
132-
133132
/*----------------------------------------------------------------------------*/
134133
TEST(CurvedBlockingTestSuite, remove_block)
135134
{
@@ -188,7 +187,6 @@ TEST(CurvedBlockingTestSuite, single_block)
188187
ASSERT_NEAR(block_center.distance(face_center), 0.5, 1e-8);
189188
}
190189
}
191-
192190
/*----------------------------------------------------------------------------*/
193191
TEST(CurvedBlockingTestSuite, single_block_parallel_edges)
194192
{
@@ -276,6 +274,44 @@ TEST(CurvedBlockingTestSuite, split_one_block_twice)
276274
ASSERT_EQ(20,bl.get_nb_cells<2>());
277275
ASSERT_EQ(4,bl.get_nb_cells<3>());
278276
}
277+
278+
/*----------------------------------------------------------------------------*/
279+
TEST(CurvedBlockingTestSuite, cut_sheet_param_propag)
280+
{
281+
282+
gmds::cad::FACManager geom_model;
283+
setUp(geom_model);
284+
gmds::blocking::CurvedBlocking bl(&geom_model, true);
285+
gmds::blocking::CurvedBlockingClassifier cl(&bl);
286+
cl.classify();
287+
288+
std::vector<gmds::blocking::CurvedBlocking::Face> all_faces = bl.get_all_faces();
289+
std::vector<gmds::blocking::CurvedBlocking::Face> surf;
290+
291+
surf.clear();
292+
//We pick a full boundary surface on coord X=5.0 and Y=5.0
293+
for(auto f:all_faces){
294+
gmds::math::Point ci = bl.get_center_of_face(f);
295+
if(fabs(ci.X()-5)<0.1){
296+
surf.push_back(f);
297+
}
298+
else if(fabs(ci.Y()-5)<0.1){
299+
surf.push_back(f);
300+
}
301+
else if(fabs(ci.Z()-5)<0.1){
302+
surf.push_back(f);
303+
}
304+
}
305+
ASSERT_TRUE(bl.pillow(surf));
306+
307+
bl.smooth(10);
308+
309+
//now we get the edge having end points of ids 1 and 2
310+
auto e = bl.get_edge(0,3);
311+
bl.cut_sheet(e,0.25);
312+
313+
ASSERT_EQ(7,bl.get_nb_cells<3>());
314+
}
279315
/*----------------------------------------------------------------------------*/
280316
TEST(CurvedBlockingTestSuite, init_from_geom_bounding_box)
281317
{
@@ -325,8 +361,6 @@ TEST(CurvedBlockingTestSuite, single_block_to_mesh)
325361
ASSERT_EQ(m.getNbFaces(), 6);
326362
ASSERT_EQ(m.getNbRegions(), 1);
327363
}
328-
329-
330364
/*----------------------------------------------------------------------------*/
331365
TEST(CurvedBlockingTestSuite, projection_point_to_edges)
332366
{
@@ -382,7 +416,6 @@ TEST(CurvedBlockingTestSuite, test_topological_queries)
382416
ASSERT_EQ(1, bs.size());
383417
}
384418
}
385-
386419
/*----------------------------------------------------------------------------*/
387420
TEST(CurvedBlockingTestSuite, test_init_from_ig_mesh)
388421
{
@@ -422,7 +455,6 @@ TEST(CurvedBlockingTestSuite, test_init_from_ig_mesh)
422455
ASSERT_EQ(16,bl.get_all_faces().size());
423456
ASSERT_EQ(3,bl.get_all_blocks().size());
424457
}
425-
426458
/*----------------------------------------------------------------------------*/
427459
TEST(CurvedBlockingTestSuite, test_chord_query)
428460
{
@@ -1129,6 +1161,7 @@ TEST(CurvedBlockingTestSuite, test_pillow_12)
11291161
ASSERT_EQ(nb_faces_on_surface, 34);
11301162
ASSERT_EQ(nb_faces_in_volume, 25);
11311163
}
1164+
/*----------------------------------------------------------------------------*/
11321165
TEST(CurvedBlockingTestSuite, save_vtk_blocking){
11331166
gmds::cad::FACManager geom_model;
11341167
setUp(geom_model);
@@ -1137,7 +1170,7 @@ TEST(CurvedBlockingTestSuite, save_vtk_blocking){
11371170

11381171
bl.save_vtk_blocking("testSaveWork.vtk");
11391172
}
1140-
1173+
/*----------------------------------------------------------------------------*/
11411174
TEST(CurvedBlockingTestSuite, get_Id_block){
11421175
gmds::cad::FACManager geom_model;
11431176
setUp(geom_model);
@@ -1157,7 +1190,7 @@ TEST(CurvedBlockingTestSuite, get_Id_block){
11571190
std::cout<<"LE BLOCK TEST "<<bl.get_block_id(block)<<std::endl;
11581191

11591192
}
1160-
1193+
/*----------------------------------------------------------------------------*/
11611194
TEST(CurvedBlockingTestSuite, check_capt_Element){
11621195
gmds::cad::FACManager geom_model;
11631196
setUp(geom_model);
@@ -1180,3 +1213,4 @@ TEST(CurvedBlockingTestSuite, check_capt_Element){
11801213
std::cout<<"Check capt possible for the curve "<< c->id()<<" : "<<bl.check_capt_element(c->id(),c->dim())<<std::endl;
11811214
}
11821215
}
1216+
/*----------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)