31 #include <SMESHDS_GroupBase.hxx> 32 #include <SMESHDS_GroupOnFilter.hxx> 33 #include <SMESHDS_GroupOnGeom.hxx> 34 #include <SMESH_ControlsDef.hxx> 35 #include <SMESH_Gen.hxx> 36 #include <SMESH_Group.hxx> 37 #include <SMESH_HypoFilter.hxx> 38 #include <SMESH_Mesh.hxx> 39 #include <StdMeshers_NumberOfSegments.hxx> 40 #include <StdMeshers_Quadrangle_2D.hxx> 41 #include <StdMeshers_Regular_1D.hxx> 42 #include <TopExp_Explorer.hxx> 43 #include <TopoDS_Shape.hxx> 45 # include <NETGENPlugin_NETGEN_2D_ONLY.hxx> 46 # include <StdMeshers_QuadranglePreference.hxx> 57 const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &
mesh,
58 std::vector<std::unique_ptr<SMESH_Hypothesis>> &generatedHyps)
const {
60 bool addedToGroup =
false;
62 bool removeOldGroup =
false;
64 auto groupDS = group->GetGroupDS();
65 if (
groupName == group->GetName() && groupDS &&
66 type == group->GetGroupDS()->GetType()) {
67 if (
auto otherGeomGroup =
68 dynamic_cast<SMESHDS_GroupOnGeom *>(groupDS)) {
69 auto otherPred = boost::make_shared<SMESH::Controls::BelongToGeom>();
70 otherPred->SetGeom(otherGeomGroup->GetShape());
71 otherPred->SetType(type);
72 auto thisPred = boost::make_shared<SMESH::Controls::BelongToGeom>();
73 thisPred->SetGeom(shape);
74 thisPred->SetType(type);
75 auto disjunction = boost::make_shared<SMESH::Controls::LogicalOR>();
76 disjunction->SetPredicate1(otherPred);
77 disjunction->SetPredicate2(thisPred);
78 mesh.AddGroup(type,
groupName.c_str(), -1, TopoDS_Shape{},
81 oldGroup = group->GetID();
82 removeOldGroup =
true;
84 }
else if (
auto otherFilterGroup =
85 dynamic_cast<SMESHDS_GroupOnFilter *>(groupDS)) {
86 auto otherPred = otherFilterGroup->GetPredicate();
87 auto thisPred = boost::make_shared<SMESH::Controls::BelongToGeom>();
88 thisPred->SetGeom(shape);
89 thisPred->SetType(type);
90 auto disjunction = boost::make_shared<SMESH::Controls::LogicalOR>();
91 disjunction->SetPredicate1(otherPred);
92 disjunction->SetPredicate2(thisPred);
93 otherFilterGroup->SetPredicate(disjunction);
99 if (!addedToGroup) { mesh.AddGroup(
type,
groupName.c_str(), -1, shape); }
100 if (removeOldGroup && oldGroup >= 0) { mesh.RemoveGroup(oldGroup); }
105 :
CRTPBase(
std::move(groupName)), numSegments_(numSegments) {}
108 const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &
mesh,
109 std::vector<std::unique_ptr<SMESH_Hypothesis>> &generatedHyps)
const {
111 auto hypId = generator.GetANewId();
112 auto hypothesis =
new StdMeshers_NumberOfSegments{hypId, &generator};
114 generatedHyps.emplace_back(hypothesis);
115 mesh.AddHypothesis(shape, hypId);
116 std::list<const SMESHDS_Hypothesis *> algos;
117 SMESH_HypoFilter filter(SMESH_HypoFilter::IsAlgo());
118 filter.And(SMESH_HypoFilter::IsApplicableTo(shape));
119 mesh.GetHypotheses(mesh.GetShapeToMesh(), filter, algos,
false);
121 for (
auto &hyp : algos) {
122 if (
auto algo = dynamic_cast<const SMESH_Algo *>(hyp)) {
126 const_cast<SMESH_Algo *
>(algo)->GetCompatibleHypothesis();
127 if (std::find(allowed_hyps.begin(), allowed_hyps.end(),
128 hypothesis->GetName()) != allowed_hyps.end()) {
129 algoId = algo->GetID();
134 algoId = generator.GetANewId();
135 auto algo =
new StdMeshers_Regular_1D{algoId, &generator};
136 generatedHyps.emplace_back(algo);
138 mesh.AddHypothesis(shape, algoId);
142 const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &
mesh,
143 std::vector<std::unique_ptr<SMESH_Hypothesis>> &generatedHyps)
const {
148 const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &
mesh,
149 std::vector<std::unique_ptr<SMESH_Hypothesis>> &generatedHyps)
const {
152 for (TopExp_Explorer explorer{shape, TopAbs_EDGE}; explorer.More();
157 auto algId = generator.GetANewId();
158 auto alg =
new StdMeshers_Quadrangle_2D{algId, &generator};
159 mesh.AddHypothesis(shape, algId);
160 generatedHyps.emplace_back(alg);
163 auto algId = generator.GetANewId();
164 auto alg =
new NETGENPlugin_NETGEN_2D_ONLY{algId, &generator};
165 mesh.AddHypothesis(shape, algId);
166 generatedHyps.emplace_back(alg);
167 auto hypId = generator.GetANewId();
168 auto hyp =
new StdMeshers_QuadranglePreference{hypId, &generator};
169 mesh.AddHypothesis(shape, hypId);
170 generatedHyps.emplace_back(hyp);
172 std::cerr <<
"Cannot generate quad-dominant mesh on general faces " void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &mesh, std::vector< std::unique_ptr< SMESH_Hypothesis >> &generatedHyps) const override
Method that is called when a GeoManager instance tries to mesh shape.
void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &mesh, std::vector< std::unique_ptr< SMESH_Hypothesis >> &generatedHyps) const override
Method that is called when a GeoManager instance tries to mesh shape.
void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &mesh, std::vector< std::unique_ptr< SMESH_Hypothesis >> &generatedHyps) const override
Method that is called when a GeoManager instance tries to mesh shape.
EdgeSegments(std::string groupName, int numSegments)
void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &mesh, std::vector< std::unique_ptr< SMESH_Hypothesis >> &generatedHyps) const override
Method that is called when a GeoManager instance tries to mesh shape.
std::shared_ptr< meshBase > mesh
void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &mesh, std::vector< std::unique_ptr< SMESH_Hypothesis >> &generatedHyps) const override
Method that is called when a GeoManager instance tries to mesh shape.
SM_StdContainerWrapperFromIter< typename std::decay< PtrSMDSIterator >::type, VALUE, EqualVALUE > containerWrapper(PtrSMDSIterator &&iter)