Skip to content

Commit 6d97994

Browse files
committed
mcts: added check for the blocks centroid to get_possible_block_removals
1 parent 0dc1630 commit 6d97994

5 files changed

Lines changed: 22 additions & 4 deletions

File tree

mctsblock/inc/gmds/mctsblock/Blocking.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class LIB_GMDS_MCTSBLOCK_API Blocking
323323
/**@brief gives access to the associated geom model
324324
* @return the internal geom model
325325
*/
326-
cad::GeomManager *geom_model();
326+
cad::GeomManager *geom_model() const;
327327
/**@brief Gives the number of @p TDim-cells in the blocking structure.
328328
* @p TDIM must be comprised in [0,3].
329329
*

mctsblock/inc/gmds/mctsblock/BlockingState.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ class LIB_GMDS_MCTSBLOCK_API BlockingState : public IState
6161
*/
6262
std::vector<std::shared_ptr<IAction>> get_possible_cuts() const;
6363

64-
/**@brief This method return all the possible block erasing. A block can be erase if it doesn't not belong a corner
65-
* that is the only one to capture a point
64+
/**@brief This method returns all the possible block erasing. A block can be erased if
65+
* - it doesn't not belong a corner that is the only one to capture a point.
66+
* - its centroid is not inside the volume
6667
* @return a vector of block ids. */
6768
std::vector<std::shared_ptr<IAction>> get_possible_block_removals() const;
6869

mctsblock/src/Blocking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Blocking::gmap()
6868

6969
/*----------------------------------------------------------------------------*/
7070
cad::GeomManager *
71-
Blocking::geom_model()
71+
Blocking::geom_model() const
7272
{
7373
return m_geom_model;
7474
}

mctsblock/src/BlockingState.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include <gmds/mctsblock/BlockingState.h>
44
#include <gmds/mctsblock/BlockingAction.h>
55
#include <gmds/utils/Exception.h>
6+
#include <gmds/cad/GeomManager.h>
7+
/*----------------------------------------------------------------------------*/
8+
#include <vector>
69
/*----------------------------------------------------------------------------*/
710
using namespace gmds;
811
using namespace gmds::mctsblock;
@@ -131,6 +134,19 @@ BlockingState::get_possible_block_removals() const
131134
}
132135
}
133136
}
137+
138+
// identify blocks with their centroid inside the geometry
139+
cad::GeomManager *geom = m_blocking->geom_model();
140+
141+
auto blocks = m_blocking->get_all_blocks();
142+
for (auto b : blocks) {
143+
gmds::math::Point pt = m_blocking->get_center_of_block(b);
144+
bool is_inside = geom->is_in(pt);
145+
if(is_inside) {
146+
blocks_to_keep.insert(m_blocking->get_block_id(b));
147+
}
148+
}
149+
134150
// all the other blocks can be removed
135151
auto all_blocks = m_blocking->get_all_id_blocks();
136152
std::vector<std::shared_ptr<IAction> > actions;

mctsblock/src/main_blocker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ int main(int argc, char* argv[])
131131
// Geometry initialization
132132
cad::FACManager geom_model;
133133
init_geom(geom_model, file_geom);
134+
geom_model.buildGTSTree();
134135

135136
// We initialize the blocking structure from the geom model
136137
mctsblock::Blocking bl(&geom_model, false);

0 commit comments

Comments
 (0)