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

importOCCShape

parent f426ce95
No related branches found
No related tags found
No related merge requests found
......@@ -240,6 +240,7 @@ class GModel
int readOCCBREP(const std::string &name);
int readOCCIGES(const std::string &name);
int readOCCSTEP(const std::string &name);
int importOCCShape(const void *shape, const void *options=0);
// Gmsh mesh file format
int readMSH(const std::string &name);
......
// $Id: GModelIO_OCC.cpp,v 1.32 2008-05-04 08:31:13 geuzaine Exp $
// $Id: GModelIO_OCC.cpp,v 1.33 2008-05-25 07:10:57 geuzaine Exp $
//
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
//
......@@ -189,7 +189,7 @@ void OCC_Internals::buildLists()
}
void OCC_Internals::HealGeometry(double tolerance, bool fixsmalledges,
void OCC_Internals::healGeometry(double tolerance, bool fixsmalledges,
bool fixspotstripfaces, bool sewfaces,
bool makesolids)
{
......@@ -348,7 +348,6 @@ void OCC_Internals::HealGeometry(double tolerance, bool fixsmalledges,
Msg::Info(" not possible");
}
}
buildLists();
}
void OCC_Internals::loadBREP(const char *fn)
......@@ -356,12 +355,12 @@ void OCC_Internals::loadBREP(const char *fn)
BRep_Builder aBuilder;
BRepTools::Read(shape, (char*)fn, aBuilder);
BRepTools::Clean(shape);
buildLists();
HealGeometry(CTX.geom.tolerance,
healGeometry(CTX.geom.tolerance,
CTX.geom.occ_fix_small_edges,
CTX.geom.occ_fix_small_faces,
CTX.geom.occ_sew_faces);
BRepTools::Clean(shape);
buildLists();
}
void OCC_Internals::loadSTEP(const char *fn)
......@@ -372,12 +371,12 @@ void OCC_Internals::loadSTEP(const char *fn)
reader.TransferRoots();
shape = reader.OneShape();
BRepTools::Clean(shape);
buildLists();
HealGeometry(CTX.geom.tolerance,
healGeometry(CTX.geom.tolerance,
CTX.geom.occ_fix_small_edges,
CTX.geom.occ_fix_small_faces,
CTX.geom.occ_sew_faces);
BRepTools::Clean(shape);
buildLists();
}
void OCC_Internals::loadIGES(const char *fn)
......@@ -388,12 +387,24 @@ void OCC_Internals::loadIGES(const char *fn)
reader.TransferRoots();
shape = reader.OneShape();
BRepTools::Clean(shape);
healGeometry(CTX.geom.tolerance,
CTX.geom.occ_fix_small_edges,
CTX.geom.occ_fix_small_faces,
CTX.geom.occ_sew_faces);
BRepTools::Clean(shape);
buildLists();
HealGeometry(CTX.geom.tolerance,
}
void OCC_Internals::loadShape(const TopoDS_Shape *s)
{
shape = *s;
BRepTools::Clean(shape);
healGeometry(CTX.geom.tolerance,
CTX.geom.occ_fix_small_edges,
CTX.geom.occ_fix_small_faces,
CTX.geom.occ_sew_faces);
BRepTools::Clean(shape);
buildLists();
}
void OCC_Internals::buildGModel(GModel *model)
......@@ -437,12 +448,12 @@ void GModel::_deleteOCCInternals()
_occ_internals = 0;
}
int GModel::readOCCSTEP(const std::string &fn)
int GModel::readOCCBREP(const std::string &fn)
{
_occ_internals = new OCC_Internals;
_occ_internals->loadSTEP(fn.c_str());
_occ_internals->buildLists();
_occ_internals->loadBREP(fn.c_str());
_occ_internals->buildGModel(this);
snapVertices();
return 1;
}
......@@ -450,34 +461,35 @@ int GModel::readOCCIGES(const std::string &fn)
{
_occ_internals = new OCC_Internals;
_occ_internals->loadIGES(fn.c_str());
_occ_internals->buildLists();
_occ_internals->buildGModel(this);
return 1;
}
int GModel::readOCCBREP(const std::string &fn)
int GModel::readOCCSTEP(const std::string &fn)
{
_occ_internals = new OCC_Internals;
_occ_internals->loadBREP(fn.c_str());
_occ_internals->buildLists();
_occ_internals->loadSTEP(fn.c_str());
_occ_internals->buildGModel(this);
snapVertices();
return 1;
}
/*
OCC Creation routines
*/
// This function has been inspired from SALOME
// It removes all duplicates from the geometry, starting
// from vertices, edges, faces, shells and solids
// This
void OCC_Internals::removeAllDuplicates (const double &tolerance){
int GModel::importOCCShape(const void *shape, const void *options)
{
_occ_internals = new OCC_Internals;
_occ_internals->loadShape((TopoDS_Shape*)shape);
_occ_internals->buildGModel(this);
return 1;
}
// This function has been inspired from SALOME It removes all
// duplicates from the geometry, starting from vertices, edges, faces,
// shells and solids This
void OCC_Internals::removeAllDuplicates(const double &tolerance)
{
}
void AddSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape& theList)
void AddSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape &theList)
{
if (theShape.ShapeType() != TopAbs_COMPOUND &&
theShape.ShapeType() != TopAbs_COMPSOLID) {
......@@ -494,7 +506,8 @@ void AddSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape& theList)
if (aShape_i.ShapeType() == TopAbs_COMPOUND ||
aShape_i.ShapeType() == TopAbs_COMPSOLID) {
AddSimpleShapes(aShape_i, theList);
} else {
}
else {
theList.Append(aShape_i);
}
}
......@@ -591,21 +604,28 @@ void GModel::_deleteOCCInternals()
int GModel::readOCCSTEP(const std::string &fn)
{
Msg::Error("Gmsh has to be compiled with OpenCascade support to load '%s'",
fn.c_str());
fn.c_str());
return 0;
}
int GModel::readOCCIGES(const std::string &fn)
{
Msg::Error("Gmsh has to be compiled with OpenCascade support to load '%s'",
fn.c_str());
fn.c_str());
return 0;
}
int GModel::readOCCBREP(const std::string &fn)
{
Msg::Error("Gmsh has to be compiled with OpenCascade support to load '%s'",
fn.c_str());
fn.c_str());
return 0;
}
int GModel::importOCCShape(const void *shape, const void *options)
{
Msg::Error("Gmsh has to be compiled with OpenCascade support to import "
"a TopoDS_Shape");
return 0;
}
......
#ifndef _GMODELIO_OCC_H_
#define _GMODELIO_OCC_H_
// $Id: GModelIO_OCC.h,v 1.5 2008-03-20 11:44:05 geuzaine Exp $
// $Id: GModelIO_OCC.h,v 1.6 2008-05-25 07:10:57 geuzaine Exp $
//
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
//
......@@ -27,14 +27,19 @@
#if defined(HAVE_OCC)
class OCC_Options {
private:
int _dummy;
public:
OCC_Options(int dummy) : _dummy(dummy){}
};
class OCC_Internals {
protected :
TopoDS_Shape shape;
TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
public:
enum BooleanOperator { Add , Cut };
enum BooleanOperator { Add, Cut };
OCC_Internals()
{
somap.Clear();
......@@ -44,19 +49,20 @@ class OCC_Internals {
emap.Clear();
vmap.Clear();
}
void HealGeometry(double tolerance, bool fixsmalledges,
void healGeometry(double tolerance, bool fixsmalledges,
bool fixspotstripfaces, bool sewfaces,
bool makesolids=false);
void loadBREP(const char *);
void loadSTEP(const char *);
void loadIGES(const char *);
void loadBREP(const char *);
void loadShape(const TopoDS_Shape *);
void buildGModel(GModel *gm);
void buildLists();
void removeAllDuplicates (const double &tolerance);
void removeAllDuplicates(const double &tolerance);
void Sphere ( const SPoint3 & center, const double & radius, const BooleanOperator & op );
void Cylinder( const SPoint3 & bottom_center, const SVector3 & dir, const BooleanOperator & op );
void applyBooleanOperator ( TopoDS_Shape tool, const BooleanOperator & op);
void Sphere(const SPoint3 &center, const double &radius, const BooleanOperator &op);
void Cylinder(const SPoint3 &bottom_center, const SVector3 &dir, const BooleanOperator &op);
void applyBooleanOperator(TopoDS_Shape tool, const BooleanOperator &op);
};
#endif
......
// $Id: OCCFace.cpp,v 1.40 2008-05-04 08:31:13 geuzaine Exp $
// $Id: OCCFace.cpp,v 1.41 2008-05-25 07:10:57 geuzaine Exp $
//
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
//
......@@ -98,7 +98,7 @@ OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num, TopTools_IndexedMapOfShape
umax += fabs(du) / 100.0;
vmax += fabs(dv) / 100.0;
occface = BRep_Tool::Surface(s);
buildSTLTriangulation();
if(!CTX.batch) buildSTLTriangulation();
}
Range<double> OCCFace::parBounds(int i) const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment