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
4c541895
Commit
4c541895
authored
18 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
use for_each like Real Men(tm) do
parent
0e5a7d87
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Geo/gmshModel.cpp
+45
-43
45 additions, 43 deletions
Geo/gmshModel.cpp
with
45 additions
and
43 deletions
Geo/gmshModel.cpp
+
45
−
43
View file @
4c541895
// $Id: gmshModel.cpp,v 1.2
0
2006-10-1
0 00:44:41
geuzaine Exp $
// $Id: gmshModel.cpp,v 1.2
1
2006-10-1
4 21:13:50
geuzaine Exp $
//
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
//
...
...
@@ -124,10 +124,11 @@ void gmshModel::import()
Msg
(
DEBUG
,
"%d Regions"
,
regions
.
size
());
}
static
FILE
*
geo
=
0
;
class
writeGVertexGEO
{
private
:
FILE
*
geo
;
public
:
writeGVertexGEO
(
FILE
*
fp
)
{
geo
=
fp
?
fp
:
stdout
;
}
void
operator
()
(
GVertex
*
gv
)
{
Vertex
*
v
=
(
Vertex
*
)
gv
->
getNativePtr
();
...
...
@@ -137,7 +138,10 @@ class writeGVertexGEO {
};
class
writeGEdgeGEO
{
private
:
FILE
*
geo
;
public
:
writeGEdgeGEO
(
FILE
*
fp
)
{
geo
=
fp
?
fp
:
stdout
;
}
void
operator
()
(
GEdge
*
ge
)
{
Curve
*
c
=
(
Curve
*
)
ge
->
getNativePtr
();
...
...
@@ -212,7 +216,10 @@ class writeGEdgeGEO {
};
class
writeGFaceGEO
{
private
:
FILE
*
geo
;
public
:
writeGFaceGEO
(
FILE
*
fp
)
{
geo
=
fp
?
fp
:
stdout
;
}
void
operator
()
(
GFace
*
gf
)
{
Surface
*
s
=
(
Surface
*
)
gf
->
getNativePtr
();
...
...
@@ -290,7 +297,10 @@ class writeGFaceGEO {
};
class
writeGRegionGEO
{
private
:
FILE
*
geo
;
public
:
writeGRegionGEO
(
FILE
*
fp
)
{
geo
=
fp
?
fp
:
stdout
;
}
void
operator
()
(
GRegion
*
gr
)
{
Volume
*
vol
=
(
Volume
*
)
gr
->
getNativePtr
();
...
...
@@ -320,51 +330,43 @@ class writeGRegionGEO {
}
};
void
writePhysicalGroupGEO
(
void
*
a
,
void
*
b
)
class
writePhysicalGroupGEO
{
private
:
FILE
*
geo
;
int
dim
;
public
:
writePhysicalGroupGEO
(
FILE
*
fp
,
int
i
)
:
dim
(
i
)
{
geo
=
fp
?
fp
:
stdout
;
}
void
operator
()
(
std
::
pair
<
const
int
,
std
::
vector
<
GEntity
*>
>
&
g
)
{
PhysicalGroup
*
pg
=
*
(
PhysicalGroup
**
)
a
;
switch
(
pg
->
Typ
)
{
case
MSH_PHYSICAL_POINT
:
fprintf
(
geo
,
"Physical Point (%d) = "
,
pg
->
Num
);
break
;
case
MSH_PHYSICAL_LINE
:
fprintf
(
geo
,
"Physical Line (%d) = "
,
pg
->
Num
);
break
;
case
MSH_PHYSICAL_SURFACE
:
fprintf
(
geo
,
"Physical Surface (%d) = "
,
pg
->
Num
);
break
;
case
MSH_PHYSICAL_VOLUME
:
fprintf
(
geo
,
"Physical Volume (%d) = "
,
pg
->
Num
);
break
;
switch
(
dim
)
{
case
0
:
fprintf
(
geo
,
"Physical Point"
);
break
;
case
1
:
fprintf
(
geo
,
"Physical Line"
);
break
;
case
2
:
fprintf
(
geo
,
"Physical Surface"
);
break
;
case
3
:
fprintf
(
geo
,
"Physical Volume"
);
break
;
}
for
(
int
i
=
0
;
i
<
List_Nbr
(
pg
->
Entities
);
i
++
)
{
int
j
;
List_Read
(
pg
->
Entities
,
i
,
&
j
);
if
(
i
)
fprintf
(
geo
,
", %d"
,
j
);
else
fprintf
(
geo
,
"{%d"
,
j
);
fprintf
(
geo
,
" (%d) = {"
,
g
.
first
);
for
(
unsigned
int
i
=
0
;
i
<
g
.
second
.
size
();
i
++
)
{
if
(
i
)
fprintf
(
geo
,
", "
);
fprintf
(
geo
,
"%d"
,
g
.
second
[
i
]
->
tag
());
}
fprintf
(
geo
,
"};
\n
"
);
}
};
int
gmshModel
::
writeGEO
(
const
std
::
string
&
name
)
{
geo
=
fopen
(
name
.
c_str
(),
"w"
);
if
(
!
geo
){
Msg
(
GERROR
,
"Unable to open file '%s'"
,
name
.
c_str
());
return
0
;
}
FILE
*
fp
=
fopen
(
name
.
c_str
(),
"w"
);
std
::
for_each
(
firstVertex
(),
lastVertex
(),
writeGVertexGEO
());
std
::
for_each
(
firstEdge
(),
lastEdge
(),
writeGEdgeGEO
());
std
::
for_each
(
firstFace
(),
lastFace
(),
writeGFaceGEO
());
std
::
for_each
(
firstRegion
(),
lastRegion
(),
writeGRegionGEO
());
std
::
for_each
(
firstVertex
(),
lastVertex
(),
writeGVertexGEO
(
fp
));
std
::
for_each
(
firstEdge
(),
lastEdge
(),
writeGEdgeGEO
(
fp
));
std
::
for_each
(
firstFace
(),
lastFace
(),
writeGFaceGEO
(
fp
));
std
::
for_each
(
firstRegion
(),
lastRegion
(),
writeGRegionGEO
(
fp
));
List_Action
(
THEM
->
PhysicalGroups
,
writePhysicalGroupGEO
);
std
::
map
<
int
,
std
::
vector
<
GEntity
*>
>
groups
[
4
];
getPhysicalGroups
(
groups
);
for
(
int
i
=
0
;
i
<
4
;
i
++
)
std
::
for_each
(
groups
[
i
].
begin
(),
groups
[
i
].
end
(),
writePhysicalGroupGEO
(
fp
,
i
));
fclose
(
geo
);
if
(
fp
)
fclose
(
fp
);
return
1
;
}
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