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 ...@@ -240,6 +240,7 @@ class GModel
int readOCCBREP(const std::string &name); int readOCCBREP(const std::string &name);
int readOCCIGES(const std::string &name); int readOCCIGES(const std::string &name);
int readOCCSTEP(const std::string &name); int readOCCSTEP(const std::string &name);
int importOCCShape(const void *shape, const void *options=0);
// Gmsh mesh file format // Gmsh mesh file format
int readMSH(const std::string &name); 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 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -189,7 +189,7 @@ void OCC_Internals::buildLists() ...@@ -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 fixspotstripfaces, bool sewfaces,
bool makesolids) bool makesolids)
{ {
...@@ -348,7 +348,6 @@ void OCC_Internals::HealGeometry(double tolerance, bool fixsmalledges, ...@@ -348,7 +348,6 @@ void OCC_Internals::HealGeometry(double tolerance, bool fixsmalledges,
Msg::Info(" not possible"); Msg::Info(" not possible");
} }
} }
buildLists();
} }
void OCC_Internals::loadBREP(const char *fn) void OCC_Internals::loadBREP(const char *fn)
...@@ -356,12 +355,12 @@ void OCC_Internals::loadBREP(const char *fn) ...@@ -356,12 +355,12 @@ void OCC_Internals::loadBREP(const char *fn)
BRep_Builder aBuilder; BRep_Builder aBuilder;
BRepTools::Read(shape, (char*)fn, aBuilder); BRepTools::Read(shape, (char*)fn, aBuilder);
BRepTools::Clean(shape); BRepTools::Clean(shape);
buildLists(); healGeometry(CTX.geom.tolerance,
HealGeometry(CTX.geom.tolerance,
CTX.geom.occ_fix_small_edges, CTX.geom.occ_fix_small_edges,
CTX.geom.occ_fix_small_faces, CTX.geom.occ_fix_small_faces,
CTX.geom.occ_sew_faces); CTX.geom.occ_sew_faces);
BRepTools::Clean(shape); BRepTools::Clean(shape);
buildLists();
} }
void OCC_Internals::loadSTEP(const char *fn) void OCC_Internals::loadSTEP(const char *fn)
...@@ -372,12 +371,12 @@ void OCC_Internals::loadSTEP(const char *fn) ...@@ -372,12 +371,12 @@ void OCC_Internals::loadSTEP(const char *fn)
reader.TransferRoots(); reader.TransferRoots();
shape = reader.OneShape(); shape = reader.OneShape();
BRepTools::Clean(shape); BRepTools::Clean(shape);
buildLists(); healGeometry(CTX.geom.tolerance,
HealGeometry(CTX.geom.tolerance,
CTX.geom.occ_fix_small_edges, CTX.geom.occ_fix_small_edges,
CTX.geom.occ_fix_small_faces, CTX.geom.occ_fix_small_faces,
CTX.geom.occ_sew_faces); CTX.geom.occ_sew_faces);
BRepTools::Clean(shape); BRepTools::Clean(shape);
buildLists();
} }
void OCC_Internals::loadIGES(const char *fn) void OCC_Internals::loadIGES(const char *fn)
...@@ -388,12 +387,24 @@ void OCC_Internals::loadIGES(const char *fn) ...@@ -388,12 +387,24 @@ void OCC_Internals::loadIGES(const char *fn)
reader.TransferRoots(); reader.TransferRoots();
shape = reader.OneShape(); shape = reader.OneShape();
BRepTools::Clean(shape); 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(); 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_edges,
CTX.geom.occ_fix_small_faces, CTX.geom.occ_fix_small_faces,
CTX.geom.occ_sew_faces); CTX.geom.occ_sew_faces);
BRepTools::Clean(shape); BRepTools::Clean(shape);
buildLists();
} }
void OCC_Internals::buildGModel(GModel *model) void OCC_Internals::buildGModel(GModel *model)
...@@ -437,12 +448,12 @@ void GModel::_deleteOCCInternals() ...@@ -437,12 +448,12 @@ void GModel::_deleteOCCInternals()
_occ_internals = 0; _occ_internals = 0;
} }
int GModel::readOCCSTEP(const std::string &fn) int GModel::readOCCBREP(const std::string &fn)
{ {
_occ_internals = new OCC_Internals; _occ_internals = new OCC_Internals;
_occ_internals->loadSTEP(fn.c_str()); _occ_internals->loadBREP(fn.c_str());
_occ_internals->buildLists();
_occ_internals->buildGModel(this); _occ_internals->buildGModel(this);
snapVertices();
return 1; return 1;
} }
...@@ -450,32 +461,33 @@ int GModel::readOCCIGES(const std::string &fn) ...@@ -450,32 +461,33 @@ int GModel::readOCCIGES(const std::string &fn)
{ {
_occ_internals = new OCC_Internals; _occ_internals = new OCC_Internals;
_occ_internals->loadIGES(fn.c_str()); _occ_internals->loadIGES(fn.c_str());
_occ_internals->buildLists();
_occ_internals->buildGModel(this); _occ_internals->buildGModel(this);
return 1; return 1;
} }
int GModel::readOCCBREP(const std::string &fn) int GModel::readOCCSTEP(const std::string &fn)
{ {
_occ_internals = new OCC_Internals; _occ_internals = new OCC_Internals;
_occ_internals->loadBREP(fn.c_str()); _occ_internals->loadSTEP(fn.c_str());
_occ_internals->buildLists();
_occ_internals->buildGModel(this); _occ_internals->buildGModel(this);
snapVertices();
return 1; return 1;
} }
/* int GModel::importOCCShape(const void *shape, const void *options)
OCC Creation routines {
*/ _occ_internals = new OCC_Internals;
_occ_internals->loadShape((TopoDS_Shape*)shape);
// This function has been inspired from SALOME _occ_internals->buildGModel(this);
// It removes all duplicates from the geometry, starting return 1;
// from vertices, edges, faces, shells and solids
// This
void OCC_Internals::removeAllDuplicates (const double &tolerance){
} }
// 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)
{ {
...@@ -494,7 +506,8 @@ void AddSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape& theList) ...@@ -494,7 +506,8 @@ void AddSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape& theList)
if (aShape_i.ShapeType() == TopAbs_COMPOUND || if (aShape_i.ShapeType() == TopAbs_COMPOUND ||
aShape_i.ShapeType() == TopAbs_COMPSOLID) { aShape_i.ShapeType() == TopAbs_COMPSOLID) {
AddSimpleShapes(aShape_i, theList); AddSimpleShapes(aShape_i, theList);
} else { }
else {
theList.Append(aShape_i); theList.Append(aShape_i);
} }
} }
...@@ -609,4 +622,11 @@ int GModel::readOCCBREP(const std::string &fn) ...@@ -609,4 +622,11 @@ int GModel::readOCCBREP(const std::string &fn)
return 0; 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;
}
#endif #endif
#ifndef _GMODELIO_OCC_H_ #ifndef _GMODELIO_OCC_H_
#define _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 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -27,14 +27,19 @@ ...@@ -27,14 +27,19 @@
#if defined(HAVE_OCC) #if defined(HAVE_OCC)
class OCC_Options {
private:
int _dummy;
public:
OCC_Options(int dummy) : _dummy(dummy){}
};
class OCC_Internals { class OCC_Internals {
protected : protected :
TopoDS_Shape shape; TopoDS_Shape shape;
TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap; TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
public: public:
enum BooleanOperator { Add, Cut }; enum BooleanOperator { Add, Cut };
OCC_Internals() OCC_Internals()
{ {
somap.Clear(); somap.Clear();
...@@ -44,12 +49,13 @@ class OCC_Internals { ...@@ -44,12 +49,13 @@ class OCC_Internals {
emap.Clear(); emap.Clear();
vmap.Clear(); vmap.Clear();
} }
void HealGeometry(double tolerance, bool fixsmalledges, void healGeometry(double tolerance, bool fixsmalledges,
bool fixspotstripfaces, bool sewfaces, bool fixspotstripfaces, bool sewfaces,
bool makesolids=false); bool makesolids=false);
void loadBREP(const char *);
void loadSTEP(const char *); void loadSTEP(const char *);
void loadIGES(const char *); void loadIGES(const char *);
void loadBREP(const char *); void loadShape(const TopoDS_Shape *);
void buildGModel(GModel *gm); void buildGModel(GModel *gm);
void buildLists(); void buildLists();
void removeAllDuplicates(const double &tolerance); void removeAllDuplicates(const double &tolerance);
......
// $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 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -98,7 +98,7 @@ OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num, TopTools_IndexedMapOfShape ...@@ -98,7 +98,7 @@ OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num, TopTools_IndexedMapOfShape
umax += fabs(du) / 100.0; umax += fabs(du) / 100.0;
vmax += fabs(dv) / 100.0; vmax += fabs(dv) / 100.0;
occface = BRep_Tool::Surface(s); occface = BRep_Tool::Surface(s);
buildSTLTriangulation(); if(!CTX.batch) buildSTLTriangulation();
} }
Range<double> OCCFace::parBounds(int i) const Range<double> OCCFace::parBounds(int i) const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment