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
c5bb63b6
Commit
c5bb63b6
authored
18 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
small simplification + color bug fix
parent
b480bad1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Geo/GModelIO.cpp
+37
-43
37 additions, 43 deletions
Geo/GModelIO.cpp
Graphics/Mesh.cpp
+3
-3
3 additions, 3 deletions
Graphics/Mesh.cpp
with
40 additions
and
46 deletions
Geo/GModelIO.cpp
+
37
−
43
View file @
c5bb63b6
// $Id: GModelIO.cpp,v 1.2
2
2006-08-18
04:27:56
geuzaine Exp $
// $Id: GModelIO.cpp,v 1.2
3
2006-08-18
15:13:34
geuzaine Exp $
//
//
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
//
//
...
@@ -30,28 +30,6 @@
...
@@ -30,28 +30,6 @@
#include
"MElement.h"
#include
"MElement.h"
#include
"SBoundingBox3d.h"
#include
"SBoundingBox3d.h"
static
int
getNumVerticesForElementTypeMSH
(
int
type
)
{
switch
(
type
)
{
case
PNT
:
return
1
;
case
LGN1
:
return
2
;
case
LGN2
:
return
2
+
1
;
case
TRI1
:
return
3
;
case
TRI2
:
return
3
+
3
;
case
QUA1
:
return
4
;
case
QUA2
:
return
4
+
4
+
1
;
case
TET1
:
return
4
;
case
TET2
:
return
4
+
6
;
case
HEX1
:
return
8
;
case
HEX2
:
return
8
+
12
+
6
+
1
;
case
PRI1
:
return
6
;
case
PRI2
:
return
6
+
9
+
3
;
case
PYR1
:
return
5
;
case
PYR2
:
return
5
+
8
+
1
;
default:
return
0
;
}
}
template
<
class
T
>
template
<
class
T
>
void
copyElements
(
std
::
vector
<
T
*>
&
dst
,
const
std
::
vector
<
MElement
*>
&
src
)
void
copyElements
(
std
::
vector
<
T
*>
&
dst
,
const
std
::
vector
<
MElement
*>
&
src
)
{
{
...
@@ -59,14 +37,15 @@ void copyElements(std::vector<T*> &dst, const std::vector<MElement*> &src)
...
@@ -59,14 +37,15 @@ void copyElements(std::vector<T*> &dst, const std::vector<MElement*> &src)
for
(
unsigned
int
i
=
0
;
i
<
src
.
size
();
i
++
)
dst
[
i
]
=
(
T
*
)
src
[
i
];
for
(
unsigned
int
i
=
0
;
i
<
src
.
size
();
i
++
)
dst
[
i
]
=
(
T
*
)
src
[
i
];
}
}
static
void
storeElementsInEntities
(
GModel
*
m
,
int
type
,
static
void
storeElementsInEntities
(
GModel
*
m
,
std
::
map
<
int
,
std
::
vector
<
MElement
*>
>
&
map
)
std
::
map
<
int
,
std
::
vector
<
MElement
*>
>
&
map
)
{
{
std
::
map
<
int
,
std
::
vector
<
MElement
*>
>::
const_iterator
it
=
map
.
begin
();
std
::
map
<
int
,
std
::
vector
<
MElement
*>
>::
const_iterator
it
=
map
.
begin
();
std
::
map
<
int
,
std
::
vector
<
MElement
*>
>::
const_iterator
ite
=
map
.
end
();
std
::
map
<
int
,
std
::
vector
<
MElement
*>
>::
const_iterator
ite
=
map
.
end
();
for
(;
it
!=
ite
;
++
it
){
for
(;
it
!=
ite
;
++
it
){
switch
(
type
){
int
numEdges
=
it
->
second
[
0
]
->
getNumEdges
();
case
LGN1
:
switch
(
numEdges
){
case
1
:
{
{
GEdge
*
e
=
m
->
edgeByTag
(
it
->
first
);
GEdge
*
e
=
m
->
edgeByTag
(
it
->
first
);
if
(
!
e
){
if
(
!
e
){
...
@@ -76,27 +55,27 @@ static void storeElementsInEntities(GModel *m, int type,
...
@@ -76,27 +55,27 @@ static void storeElementsInEntities(GModel *m, int type,
copyElements
(
e
->
lines
,
it
->
second
);
copyElements
(
e
->
lines
,
it
->
second
);
}
}
break
;
break
;
case
TRI1
:
case
QUA1
:
case
3
:
case
4
:
{
{
GFace
*
f
=
m
->
faceByTag
(
it
->
first
);
GFace
*
f
=
m
->
faceByTag
(
it
->
first
);
if
(
!
f
){
if
(
!
f
){
f
=
new
gmshFace
(
m
,
it
->
first
);
f
=
new
gmshFace
(
m
,
it
->
first
);
m
->
add
(
f
);
m
->
add
(
f
);
}
}
if
(
type
==
TRI1
)
copyElements
(
f
->
triangles
,
it
->
second
);
if
(
numEdges
==
3
)
copyElements
(
f
->
triangles
,
it
->
second
);
else
copyElements
(
f
->
quadrangles
,
it
->
second
);
else
copyElements
(
f
->
quadrangles
,
it
->
second
);
}
}
break
;
break
;
case
TET1
:
case
HEX
1
:
case
PRI1
:
case
PYR1
:
case
6
:
case
1
2
:
case
9
:
case
8
:
{
{
GRegion
*
r
=
m
->
regionByTag
(
it
->
first
);
GRegion
*
r
=
m
->
regionByTag
(
it
->
first
);
if
(
!
r
){
if
(
!
r
){
r
=
new
gmshRegion
(
m
,
it
->
first
);
r
=
new
gmshRegion
(
m
,
it
->
first
);
m
->
add
(
r
);
m
->
add
(
r
);
}
}
if
(
type
==
TET1
)
copyElements
(
r
->
tetrahedra
,
it
->
second
);
if
(
numEdges
==
6
)
copyElements
(
r
->
tetrahedra
,
it
->
second
);
else
if
(
type
==
HEX1
)
copyElements
(
r
->
hexahedra
,
it
->
second
);
else
if
(
numEdges
==
12
)
copyElements
(
r
->
hexahedra
,
it
->
second
);
else
if
(
type
==
PRI1
)
copyElements
(
r
->
prisms
,
it
->
second
);
else
if
(
numEdges
==
9
)
copyElements
(
r
->
prisms
,
it
->
second
);
else
copyElements
(
r
->
pyramids
,
it
->
second
);
else
copyElements
(
r
->
pyramids
,
it
->
second
);
}
}
break
;
break
;
...
@@ -184,6 +163,28 @@ static void storePhysicalTagsInEntities(GModel *m, int dim,
...
@@ -184,6 +163,28 @@ static void storePhysicalTagsInEntities(GModel *m, int dim,
}
}
}
}
static
int
getNumVerticesForElementTypeMSH
(
int
type
)
{
switch
(
type
)
{
case
PNT
:
return
1
;
case
LGN1
:
return
2
;
case
LGN2
:
return
2
+
1
;
case
TRI1
:
return
3
;
case
TRI2
:
return
3
+
3
;
case
QUA1
:
return
4
;
case
QUA2
:
return
4
+
4
+
1
;
case
TET1
:
return
4
;
case
TET2
:
return
4
+
6
;
case
HEX1
:
return
8
;
case
HEX2
:
return
8
+
12
+
6
+
1
;
case
PRI1
:
return
6
;
case
PRI2
:
return
6
+
9
+
3
;
case
PYR1
:
return
5
;
case
PYR2
:
return
5
+
8
+
1
;
default:
return
0
;
}
}
int
GModel
::
readMSH
(
const
std
::
string
&
name
)
int
GModel
::
readMSH
(
const
std
::
string
&
name
)
{
{
FILE
*
fp
=
fopen
(
name
.
c_str
(),
"r"
);
FILE
*
fp
=
fopen
(
name
.
c_str
(),
"r"
);
...
@@ -192,7 +193,6 @@ int GModel::readMSH(const std::string &name)
...
@@ -192,7 +193,6 @@ int GModel::readMSH(const std::string &name)
return
0
;
return
0
;
}
}
int
elementTypes
[
7
]
=
{
LGN1
,
TRI1
,
QUA1
,
TET1
,
HEX1
,
PRI1
,
PYR1
};
double
version
=
1.0
;
double
version
=
1.0
;
char
str
[
256
];
char
str
[
256
];
std
::
map
<
int
,
MVertex
*>
vertices
;
std
::
map
<
int
,
MVertex
*>
vertices
;
...
@@ -395,8 +395,7 @@ int GModel::readMSH(const std::string &name)
...
@@ -395,8 +395,7 @@ int GModel::readMSH(const std::string &name)
// store the elements in their associated elementary entity. If the
// store the elements in their associated elementary entity. If the
// entity does not exist, create a new one.
// entity does not exist, create a new one.
for
(
int
i
=
0
;
i
<
7
;
i
++
)
for
(
int
i
=
0
;
i
<
7
;
i
++
)
storeElementsInEntities
(
this
,
elements
[
i
]);
storeElementsInEntities
(
this
,
elementTypes
[
i
],
elements
[
i
]);
// treat points separately
// treat points separately
{
{
...
@@ -843,13 +842,11 @@ int GModel::readVRML(const std::string &name)
...
@@ -843,13 +842,11 @@ int GModel::readVRML(const std::string &name)
return
0
;
return
0
;
}
}
// This is by NO means a complete VRML/Inventor parser
!
(
B
ut it's
// This is by NO means a complete VRML/Inventor parser (
b
ut it's
// sufficient for reading simple Inventor files... which is all I
// sufficient for reading simple Inventor files... which is all I
// need)
// need)
std
::
map
<
int
,
MVertex
*>
vertices
;
std
::
map
<
int
,
MVertex
*>
vertices
;
std
::
vector
<
MVertex
*>
allvertices
;
std
::
vector
<
MVertex
*>
allvertices
;
int
elementTypes
[
3
]
=
{
LGN1
,
TRI1
,
QUA1
};
std
::
map
<
int
,
std
::
vector
<
MElement
*>
>
elements
[
3
];
std
::
map
<
int
,
std
::
vector
<
MElement
*>
>
elements
[
3
];
int
region
=
0
;
int
region
=
0
;
char
buffer
[
256
],
str
[
256
];
char
buffer
[
256
],
str
[
256
];
...
@@ -887,8 +884,7 @@ int GModel::readVRML(const std::string &name)
...
@@ -887,8 +884,7 @@ int GModel::readVRML(const std::string &name)
}
}
}
}
for
(
int
i
=
0
;
i
<
3
;
i
++
)
for
(
int
i
=
0
;
i
<
3
;
i
++
)
storeElementsInEntities
(
this
,
elements
[
i
]);
storeElementsInEntities
(
this
,
elementTypes
[
i
],
elements
[
i
]);
associateEntityWithVertices
(
this
);
associateEntityWithVertices
(
this
);
storeVerticesInEntities
(
allvertices
);
storeVerticesInEntities
(
allvertices
);
...
@@ -1088,7 +1084,6 @@ int GModel::readMESH(const std::string &name)
...
@@ -1088,7 +1084,6 @@ int GModel::readMESH(const std::string &name)
}
}
std
::
map
<
int
,
MVertex
*>
vertices
;
std
::
map
<
int
,
MVertex
*>
vertices
;
int
elementTypes
[
2
]
=
{
TRI1
,
QUA1
};
std
::
map
<
int
,
std
::
vector
<
MElement
*>
>
elements
[
2
];
std
::
map
<
int
,
std
::
vector
<
MElement
*>
>
elements
[
2
];
while
(
!
feof
(
fp
))
{
while
(
!
feof
(
fp
))
{
...
@@ -1142,8 +1137,7 @@ int GModel::readMESH(const std::string &name)
...
@@ -1142,8 +1137,7 @@ int GModel::readMESH(const std::string &name)
// store the elements in their associated elementary entity. If the
// store the elements in their associated elementary entity. If the
// entity does not exist, create a new one.
// entity does not exist, create a new one.
for
(
int
i
=
0
;
i
<
2
;
i
++
)
for
(
int
i
=
0
;
i
<
2
;
i
++
)
storeElementsInEntities
(
this
,
elements
[
i
]);
storeElementsInEntities
(
this
,
elementTypes
[
i
],
elements
[
i
]);
// associate the correct geometrical entity with each mesh vertex
// associate the correct geometrical entity with each mesh vertex
associateEntityWithVertices
(
this
);
associateEntityWithVertices
(
this
);
...
...
This diff is collapsed.
Click to expand it.
Graphics/Mesh.cpp
+
3
−
3
View file @
c5bb63b6
// $Id: Mesh.cpp,v 1.17
6
2006-08-1
7
1
7:08:51
geuzaine Exp $
// $Id: Mesh.cpp,v 1.17
7
2006-08-1
8
1
5:13:34
geuzaine Exp $
//
//
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
//
//
...
@@ -38,7 +38,7 @@ static unsigned int getColorByElement(MElement *ele)
...
@@ -38,7 +38,7 @@ static unsigned int getColorByElement(MElement *ele)
{
{
if
(
CTX
.
mesh
.
color_carousel
==
0
){
// by element type
if
(
CTX
.
mesh
.
color_carousel
==
0
){
// by element type
switch
(
ele
->
getNumEdges
()){
switch
(
ele
->
getNumEdges
()){
case
0
:
return
CTX
.
color
.
mesh
.
line
;
case
1
:
return
CTX
.
color
.
mesh
.
line
;
case
3
:
return
CTX
.
color
.
mesh
.
triangle
;
case
3
:
return
CTX
.
color
.
mesh
.
triangle
;
case
4
:
return
CTX
.
color
.
mesh
.
quadrangle
;
case
4
:
return
CTX
.
color
.
mesh
.
quadrangle
;
case
6
:
return
CTX
.
color
.
mesh
.
tetrahedron
;
case
6
:
return
CTX
.
color
.
mesh
.
tetrahedron
;
...
@@ -66,7 +66,7 @@ static unsigned int getColorByEntity(GEntity *e)
...
@@ -66,7 +66,7 @@ static unsigned int getColorByEntity(GEntity *e)
default:
return
CTX
.
color
.
geom
.
volume_sel
;
default:
return
CTX
.
color
.
geom
.
volume_sel
;
}
}
}
}
else
if
(
e
->
useColor
()){
// forced
input files
else
if
(
e
->
useColor
()){
// forced
from a script
return
e
->
getColor
();
return
e
->
getColor
();
}
}
else
if
(
CTX
.
mesh
.
color_carousel
==
1
){
// by elementary entity
else
if
(
CTX
.
mesh
.
color_carousel
==
1
){
// by elementary entity
...
...
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