Skip to content
Snippets Groups Projects
Commit c4f25e5d authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

refactor occMeshConstraints + add missing writeOCC functions
parent 9d2f8599
No related branches found
No related tags found
No related merge requests found
...@@ -325,10 +325,10 @@ class GModel ...@@ -325,10 +325,10 @@ class GModel
// OCC model // OCC model
int readOCCBREP(const std::string &name); int readOCCBREP(const std::string &name);
int writeOCCBREP(const std::string &name);
int readOCCIGES(const std::string &name);
int readOCCSTEP(const std::string &name); int readOCCSTEP(const std::string &name);
int readOCCIGES(const std::string &name);
int writeOCCSTEP(const std::string &name); int writeOCCSTEP(const std::string &name);
int writeOCCBREP(const std::string &name);
int importOCCShape(const void *shape); int importOCCShape(const void *shape);
int applyOCCMeshConstraints(const void *constraints); int applyOCCMeshConstraints(const void *constraints);
void addShape(std::string name, std::vector<double> &p, std::string op); void addShape(std::string name, std::vector<double> &p, std::string op);
......
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#include "GEdgeCompound.h" #include "GEdgeCompound.h"
#include "GFaceCompound.h" #include "GFaceCompound.h"
#include <iostream> // DBG
void GModel::_storePhysicalTagsInEntities(int dim, void GModel::_storePhysicalTagsInEntities(int dim,
std::map<int, std::map<int, std::string> > &map) std::map<int, std::map<int, std::string> > &map)
{ {
......
...@@ -889,6 +889,22 @@ int GModel::readOCCBREP(const std::string &fn) ...@@ -889,6 +889,22 @@ int GModel::readOCCBREP(const std::string &fn)
return 1; return 1;
} }
int GModel::readOCCSTEP(const std::string &fn)
{
_occ_internals = new OCC_Internals;
_occ_internals->loadSTEP(fn.c_str());
_occ_internals->buildGModel(this);
return 1;
}
int GModel::readOCCIGES(const std::string &fn)
{
_occ_internals = new OCC_Internals;
_occ_internals->loadIGES(fn.c_str());
_occ_internals->buildGModel(this);
return 1;
}
int GModel::writeOCCBREP(const std::string &fn) int GModel::writeOCCBREP(const std::string &fn)
{ {
if (!_occ_internals){ if (!_occ_internals){
...@@ -911,22 +927,6 @@ int GModel::writeOCCSTEP(const std::string &fn) ...@@ -911,22 +927,6 @@ int GModel::writeOCCSTEP(const std::string &fn)
return 1; return 1;
} }
int GModel::readOCCIGES(const std::string &fn)
{
_occ_internals = new OCC_Internals;
_occ_internals->loadIGES(fn.c_str());
_occ_internals->buildGModel(this);
return 1;
}
int GModel::readOCCSTEP(const std::string &fn)
{
_occ_internals = new OCC_Internals;
_occ_internals->loadSTEP(fn.c_str());
_occ_internals->buildGModel(this);
return 1;
}
int GModel::importOCCShape(const void *shape) int GModel::importOCCShape(const void *shape)
{ {
_occ_internals = new OCC_Internals; _occ_internals = new OCC_Internals;
...@@ -937,37 +937,32 @@ int GModel::importOCCShape(const void *shape) ...@@ -937,37 +937,32 @@ int GModel::importOCCShape(const void *shape)
return 1; return 1;
} }
int GModel::applyOCCMeshConstraints(const void *constraints)
{
#if defined(HAVE_OCC_MESH_CONSTRAINTS) #if defined(HAVE_OCC_MESH_CONSTRAINTS)
// FIXME !!!!!!!!!!!!!!!! static void _applyOCCMeshConstraintsOnVertices
// COMPUTE 1D MESH AUTOMATICALLY WHEN NO CONSTRAINTS ARE APPLIED (GModel *m, MeshGmsh_DataMapOfShapeOfVertexConstrain &constraints)
// ON SOME GEDGES !!!!!!!!!!!!!!!!!! {
MeshGmsh_Constrain *meshConstraints = (MeshGmsh_Constrain*)constraints; for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); ++it){
// apply mesh constraints on model vertices
MeshGmsh_DataMapOfShapeOfVertexConstrain vertexConstraints;
meshConstraints->GetVertexConstrain(vertexConstraints);
for(GModel::viter it = firstVertex(); it != lastVertex(); ++it){
GVertex *gv = *it; GVertex *gv = *it;
if(gv->getNativeType() != GEntity::OpenCascadeModel) continue; if(gv->getNativeType() != GEntity::OpenCascadeModel) continue;
TopoDS_Shape *s = (TopoDS_Shape*)gv->getNativePtr(); TopoDS_Shape *s = (TopoDS_Shape*)gv->getNativePtr();
if(vertexConstraints.IsBound(*s)) { if(constraints.IsBound(*s)) {
Msg::Debug("Found mesh contraints on vertex %d", gv->tag()); Msg::Debug("Found mesh contraints on vertex %d", gv->tag());
const MeshGmsh_VertexConstrain &c(vertexConstraints.Find(*s)); const MeshGmsh_VertexConstrain &c(constraints.Find(*s));
// characteristic length constraint
// 1) characteristic length constraint
double lc = c.GetSize(); double lc = c.GetSize();
if(lc >= 0.){ if(lc >= 0.){
Msg::Debug("... setting mesh size = %g", lc); Msg::Debug("... setting mesh size = %g", lc);
gv->setPrescribedMeshSizeAtVertex(lc); gv->setPrescribedMeshSizeAtVertex(lc);
} }
// embedding constraint
// 2) embedding constraint
if(c.IsEmbedded() && !c.GetFace().IsNull()){ if(c.IsEmbedded() && !c.GetFace().IsNull()){
TopoDS_Shape shape = c.GetFace(); TopoDS_Shape shape = c.GetFace();
Standard_Integer nodeNum; Standard_Integer nodeNum;
c.GetNodeNumber(nodeNum); c.GetNodeNumber(nodeNum);
for(GModel::fiter it2 = firstFace(); it2 != lastFace(); ++it2){ for(GModel::fiter it2 = m->firstFace(); it2 != m->lastFace(); ++it2){
GFace *gf = *it2; GFace *gf = *it2;
if(gf->getNativeType() != GEntity::OpenCascadeModel) continue; if(gf->getNativeType() != GEntity::OpenCascadeModel) continue;
TopoDS_Shape *shape2 = (TopoDS_Shape*)gf->getNativePtr(); TopoDS_Shape *shape2 = (TopoDS_Shape*)gf->getNativePtr();
...@@ -980,18 +975,20 @@ int GModel::applyOCCMeshConstraints(const void *constraints) ...@@ -980,18 +975,20 @@ int GModel::applyOCCMeshConstraints(const void *constraints)
} }
} }
} }
}
// apply mesh constraints on model edges static void _applyOCCMeshConstraintsOnEdges
MeshGmsh_DataMapOfShapeOfEdgeConstrain edgeConstraints; (GModel *m, MeshGmsh_DataMapOfShapeOfEdgeConstrain &constraints)
meshConstraints->GetEdgeConstrain(edgeConstraints); {
for(GModel::eiter it = firstEdge(); it != lastEdge(); ++it){ for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); ++it){
GEdge *ge = *it; GEdge *ge = *it;
if(ge->getNativeType() != GEntity::OpenCascadeModel) continue; if(ge->getNativeType() != GEntity::OpenCascadeModel) continue;
TopoDS_Shape *s = (TopoDS_Shape*)ge->getNativePtr(); TopoDS_Shape *s = (TopoDS_Shape*)ge->getNativePtr();
if(edgeConstraints.IsBound(*s)) { if(constraints.IsBound(*s)) {
Msg::Debug("Found mesh contraints on edge %d", ge->tag()); Msg::Debug("Found mesh contraints on edge %d", ge->tag());
const MeshGmsh_EdgeConstrain &c(edgeConstraints.Find(*s)); const MeshGmsh_EdgeConstrain &c(constraints.Find(*s));
// prescribed mesh constraint
// 1) prescribed mesh constraint
if(c.IsMeshImposed()){ if(c.IsMeshImposed()){
TColStd_SequenceOfInteger nodeNum; TColStd_SequenceOfInteger nodeNum;
c.GetNodesNumber(nodeNum); c.GetNodesNumber(nodeNum);
...@@ -1035,10 +1032,11 @@ int GModel::applyOCCMeshConstraints(const void *constraints) ...@@ -1035,10 +1032,11 @@ int GModel::applyOCCMeshConstraints(const void *constraints)
} }
} }
} }
// embedding constraint
// 2) embedding constraint
if(c.IsEmbedded() && !c.GetFace().IsNull()){ if(c.IsEmbedded() && !c.GetFace().IsNull()){
TopoDS_Shape shape = c.GetFace(); TopoDS_Shape shape = c.GetFace();
for(GModel::fiter it2 = firstFace(); it2 != lastFace(); ++it2){ for(GModel::fiter it2 = m->firstFace(); it2 != m->lastFace(); ++it2){
GFace *gf = *it2; GFace *gf = *it2;
if(gf->getNativeType() != GEntity::OpenCascadeModel) continue; if(gf->getNativeType() != GEntity::OpenCascadeModel) continue;
TopoDS_Shape *shape2 = (TopoDS_Shape*)gf->getNativePtr(); TopoDS_Shape *shape2 = (TopoDS_Shape*)gf->getNativePtr();
...@@ -1053,6 +1051,27 @@ int GModel::applyOCCMeshConstraints(const void *constraints) ...@@ -1053,6 +1051,27 @@ int GModel::applyOCCMeshConstraints(const void *constraints)
} }
} }
} }
// FIXME: compute better characteristic length for all edges with no
// imposed mesh? Or mesh those edges directly (here?)
for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); ++it){
// ...
}
}
#endif
int GModel::applyOCCMeshConstraints(const void *constraints)
{
#if defined(HAVE_OCC_MESH_CONSTRAINTS)
MeshGmsh_Constrain *c = (MeshGmsh_Constrain*)constraints;
MeshGmsh_DataMapOfShapeOfVertexConstrain vertexConstraints;
c->GetVertexConstrain(vertexConstraints);
_applyOCCMeshConstraintsOnVertices(vertexConstraints);
MeshGmsh_DataMapOfShapeOfEdgeConstrain edgeConstraints;
c->GetEdgeConstrain(edgeConstraints);
_applyOCCMeshConstraintsOnEdges(edgeConstraints);
return 1; return 1;
#else #else
return 0; return 0;
...@@ -1065,6 +1084,13 @@ void GModel::_deleteOCCInternals() ...@@ -1065,6 +1084,13 @@ void GModel::_deleteOCCInternals()
{ {
} }
int GModel::readOCCBREP(const std::string &fn)
{
Msg::Error("Gmsh must be compiled with OpenCascade support to load '%s'",
fn.c_str());
return 0;
}
int GModel::readOCCSTEP(const std::string &fn) int GModel::readOCCSTEP(const std::string &fn)
{ {
Msg::Error("Gmsh must be compiled with OpenCascade support to load '%s'", Msg::Error("Gmsh must be compiled with OpenCascade support to load '%s'",
...@@ -1079,9 +1105,16 @@ int GModel::readOCCIGES(const std::string &fn) ...@@ -1079,9 +1105,16 @@ int GModel::readOCCIGES(const std::string &fn)
return 0; return 0;
} }
int GModel::readOCCBREP(const std::string &fn) int GModel::writeOCCBREP(const std::string &fn)
{ {
Msg::Error("Gmsh must be compiled with OpenCascade support to load '%s'", Msg::Error("Gmsh must be compiled with OpenCascade support to write '%s'",
fn.c_str());
return 0;
}
int GModel::writeOCCSTEP(const std::string &fn)
{
Msg::Error("Gmsh must be compiled with OpenCascade support to write '%s'",
fn.c_str()); fn.c_str());
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment