Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
029b6ef3
Commit
029b6ef3
authored
16 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
importOCCShape
parent
f426ce95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Geo/GModel.h
+1
-0
1 addition, 0 deletions
Geo/GModel.h
Geo/GModelIO_OCC.cpp
+50
-30
50 additions, 30 deletions
Geo/GModelIO_OCC.cpp
Geo/GModelIO_OCC.h
+16
-10
16 additions, 10 deletions
Geo/GModelIO_OCC.h
Geo/OCCFace.cpp
+2
-2
2 additions, 2 deletions
Geo/OCCFace.cpp
with
69 additions
and
42 deletions
Geo/GModel.h
+
1
−
0
View file @
029b6ef3
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Geo/GModelIO_OCC.cpp
+
50
−
30
View file @
029b6ef3
// $Id: GModelIO_OCC.cpp,v 1.3
2
2008-05-
04 08:31:13
geuzaine Exp $
// $Id: GModelIO_OCC.cpp,v 1.3
3
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
::
H
ealGeometry
(
double
tolerance
,
bool
fixsmalledges
,
void
OCC_Internals
::
h
ealGeometry
(
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
::
readOCC
ST
EP
(
const
std
::
string
&
fn
)
int
GModel
::
readOCC
BR
EP
(
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
::
readOCC
BR
EP
(
const
std
::
string
&
fn
)
int
GModel
::
readOCC
ST
EP
(
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
;
}
...
...
This diff is collapsed.
Click to expand it.
Geo/GModelIO_OCC.h
+
16
−
10
View file @
029b6ef3
#ifndef _GMODELIO_OCC_H_
#define _GMODELIO_OCC_H_
// $Id: GModelIO_OCC.h,v 1.
5
2008-0
3
-2
0 11:44:05
geuzaine Exp $
// $Id: GModelIO_OCC.h,v 1.
6
2008-0
5
-2
5 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
H
ealGeometry
(
double
tolerance
,
bool
fixsmalledges
,
void
h
ealGeometry
(
double
tolerance
,
bool
fixsmalledges
,
bool
fixspotstripfaces
,
bool
sewfaces
,
bool
makesolids
=
false
);
void
loadBREP
(
const
char
*
);
void
loadSTEP
(
const
char
*
);
void
loadIGES
(
const
char
*
);
void
load
BREP
(
const
char
*
);
void
load
Shape
(
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
...
...
This diff is collapsed.
Click to expand it.
Geo/OCCFace.cpp
+
2
−
2
View file @
029b6ef3
// $Id: OCCFace.cpp,v 1.4
0
2008-05-
04 08:31:13
geuzaine Exp $
// $Id: OCCFace.cpp,v 1.4
1
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment