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

test importOCCShape

parent 4280c455
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
// //
// Please report all bugs and problems to <gmsh@geuz.org>. // Please report all bugs and problems to <gmsh@geuz.org>.
int GmshInitialize(int argc, char **argv); int GmshInitialize(int argc=0, char **argv=0);
int GmshFinalize(); int GmshFinalize();
int GmshBatch(); int GmshBatch();
......
// $Id: GModelIO_OCC.cpp,v 1.33 2008-05-25 07:10:57 geuzaine Exp $ // $Id: GModelIO_OCC.cpp,v 1.34 2008-06-03 07:25:07 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -279,7 +279,7 @@ void OCC_Internals::healGeometry(double tolerance, bool fixsmalledges, ...@@ -279,7 +279,7 @@ void OCC_Internals::healGeometry(double tolerance, bool fixsmalledges,
if(fixspotstripfaces){ if(fixspotstripfaces){
Msg::Info("- fixing spot and strip faces"); Msg::Info("- fixing spot and strip faces");
Handle(ShapeFix_FixSmallFace) sffsm = new ShapeFix_FixSmallFace(); Handle(ShapeFix_FixSmallFace) sffsm = new ShapeFix_FixSmallFace;
sffsm->Init(shape); sffsm->Init(shape);
sffsm->SetPrecision(tolerance); sffsm->SetPrecision(tolerance);
sffsm->Perform(); sffsm->Perform();
...@@ -399,11 +399,12 @@ void OCC_Internals::loadShape(const TopoDS_Shape *s) ...@@ -399,11 +399,12 @@ void OCC_Internals::loadShape(const TopoDS_Shape *s)
{ {
shape = *s; shape = *s;
BRepTools::Clean(shape); BRepTools::Clean(shape);
healGeometry(CTX.geom.tolerance, // FIXME should we apply the healing stuff when we import a shape?
CTX.geom.occ_fix_small_edges, // healGeometry(CTX.geom.tolerance,
CTX.geom.occ_fix_small_faces, // CTX.geom.occ_fix_small_edges,
CTX.geom.occ_sew_faces); // CTX.geom.occ_fix_small_faces,
BRepTools::Clean(shape); // CTX.geom.occ_sew_faces);
// BRepTools::Clean(shape);
buildLists(); buildLists();
} }
...@@ -478,6 +479,10 @@ int GModel::importOCCShape(const void *shape, const void *options) ...@@ -478,6 +479,10 @@ int GModel::importOCCShape(const void *shape, const void *options)
_occ_internals = new OCC_Internals; _occ_internals = new OCC_Internals;
_occ_internals->loadShape((TopoDS_Shape*)shape); _occ_internals->loadShape((TopoDS_Shape*)shape);
_occ_internals->buildGModel(this); _occ_internals->buildGModel(this);
snapVertices();
// FIXME remove this when CL API is done
extern void SetBoundingBox();
SetBoundingBox();
return 1; return 1;
} }
......
...@@ -25,5 +25,6 @@ int main(int argc, char **argv) ...@@ -25,5 +25,6 @@ int main(int argc, char **argv)
} }
m->writeMSH("test.msh"); m->writeMSH("test.msh");
m->writeUNV("test.unv"); m->writeUNV("test.unv");
delete m;
GmshFinalize(); GmshFinalize();
} }
// g++ -I/usr/local/opencascade/inc driverOCC.cpp -lGmsh -L/usr/local/opencascade/lib -lTKSTEP -lTKSTEP209 -lTKSTEPAttr -lTKSTEPBase -lTKIGES -lTKXSBase -lTKOffset -lTKFeat -lTKFillet -lTKBool -lTKShHealing -lTKMesh -lTKHLR -lTKBO -lTKPrim -lTKTopAlgo -lTKGeomAlgo -lTKBRep -lTKGeomBase -lTKG3d -lTKG2d -lTKAdvTools -lTKMath -lTKernel -lm
#if !defined(WIN32) || defined(__CYGWIN__)
#include "config.h"
#endif
#include "TopoDS_Shape.hxx"
#include "BRep_Tool.hxx"
#include "BRep_Builder.hxx"
#include "BRepTools.hxx"
#include <stdio.h>
#include <gmsh/Gmsh.h>
#include <gmsh/GModel.h>
#include <gmsh/MElement.h>
int main(int argc, char **argv)
{
// create an OCC shape (by loading it from a brep file)
TopoDS_Shape shape;
BRep_Builder builder;
BRepTools::Read(shape, argv[1], builder);
BRepTools::Clean(shape);
// import the shape in gmsh and mesh it
GmshInitialize(argc, argv);
GModel *m = new GModel();
m->importOCCShape((void*)&shape, 0);
m->mesh(2);
for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); ++it){
GRegion *r = *it;
printf("volume %d contains %d elements:\n", r->tag(), r->getNumMeshElements());
for(unsigned int i = 0; i < r->getNumMeshElements(); i++)
printf(" %d", r->getMeshElement(i)->getNum());
printf("\n");
}
m->writeMSH("test.msh");
delete m;
GmshFinalize();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment