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
09139c8e
Commit
09139c8e
authored
18 years ago
by
Stefen Guzik
Browse files
Options
Downloads
Patches
Plain Diff
- stores sorted order of vertex addresses
- added Equal, Less, and Hash function objects for MEdge and MEdge*
parent
b4de12ef
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Geo/MEdge.h
+78
-7
78 additions, 7 deletions
Geo/MEdge.h
with
78 additions
and
7 deletions
Geo/MEdge.h
+
78
−
7
View file @
09139c8e
...
@@ -20,24 +20,36 @@
...
@@ -20,24 +20,36 @@
//
//
// Please report all bugs and problems to <gmsh@geuz.org>.
// Please report all bugs and problems to <gmsh@geuz.org>.
#include
<functional>
#include
"MVertex.h"
#include
"MVertex.h"
#include
"SVector3.h"
#include
"SVector3.h"
#include
"Hash.h"
// A mesh edge.
// A mesh edge.
class
MEdge
{
class
MEdge
{
private:
private:
MVertex
*
_v
[
2
];
MVertex
*
_v
[
2
];
char
_si
[
2
];
// sorted indices
public:
public:
MEdge
(
MVertex
*
v0
,
MVertex
*
v1
)
MEdge
(
MVertex
*
v0
,
MVertex
*
v1
)
{
{
_v
[
0
]
=
v0
;
_v
[
1
]
=
v1
;
_v
[
0
]
=
v0
;
_v
[
1
]
=
v1
;
if
(
_v
[
1
]
<
_v
[
0
])
{
_si
[
0
]
=
1
;
_si
[
1
]
=
0
;
}
else
{
_si
[
0
]
=
0
;
_si
[
1
]
=
1
;
}
}
}
inline
int
getNumVertices
()
const
{
return
2
;
}
inline
int
getNumVertices
()
const
{
return
2
;
}
inline
MVertex
*
getVertex
(
int
i
)
const
{
return
_v
[
i
];
}
inline
MVertex
*
getVertex
(
const
int
i
)
const
{
return
_v
[
i
];
}
inline
MVertex
*
getMinVertex
()
const
{
return
std
::
min
(
_v
[
0
],
_v
[
1
]);
}
inline
MVertex
*
getSortedVertex
(
const
int
i
)
const
{
return
_v
[
int
(
_si
[
i
])];
}
inline
MVertex
*
getMaxVertex
()
const
{
return
std
::
max
(
_v
[
0
],
_v
[
1
]);
}
inline
MVertex
*
getMinVertex
()
const
{
return
_v
[
int
(
_si
[
0
])];
}
SVector3
tangent
()
inline
MVertex
*
getMaxVertex
()
const
{
return
_v
[
int
(
_si
[
1
])];
}
SVector3
tangent
()
const
{
{
SVector3
t
(
_v
[
1
]
->
x
()
-
_v
[
0
]
->
x
(),
SVector3
t
(
_v
[
1
]
->
x
()
-
_v
[
0
]
->
x
(),
_v
[
1
]
->
y
()
-
_v
[
0
]
->
y
(),
_v
[
1
]
->
y
()
-
_v
[
0
]
->
y
(),
...
@@ -45,7 +57,7 @@ class MEdge {
...
@@ -45,7 +57,7 @@ class MEdge {
t
.
normalize
();
t
.
normalize
();
return
t
;
return
t
;
}
}
SPoint3
barycenter
()
SPoint3
barycenter
()
const
{
{
return
SPoint3
(
0.5
*
(
_v
[
0
]
->
x
()
+
_v
[
1
]
->
x
()),
return
SPoint3
(
0.5
*
(
_v
[
0
]
->
x
()
+
_v
[
1
]
->
x
()),
0.5
*
(
_v
[
0
]
->
y
()
+
_v
[
1
]
->
y
()),
0.5
*
(
_v
[
0
]
->
y
()
+
_v
[
1
]
->
y
()),
...
@@ -53,4 +65,63 @@ class MEdge {
...
@@ -53,4 +65,63 @@ class MEdge {
}
}
};
};
//--The following function objects compare the addresses of the mesh vertices.
//--Equal, Less, and a Hash are defined.
struct
Equal_Edge
:
public
std
::
binary_function
<
MEdge
,
MEdge
,
bool
>
{
bool
operator
()(
const
MEdge
&
e1
,
const
MEdge
&
e2
)
const
{
return
(
e1
.
getMinVertex
()
==
e2
.
getMinVertex
()
&&
e1
.
getMaxVertex
()
==
e2
.
getMaxVertex
());
}
};
struct
Equal_EdgePtr
:
public
std
::
binary_function
<
MEdge
*
,
MEdge
*
,
bool
>
{
bool
operator
()(
const
MEdge
*
const
e1
,
const
MEdge
*
const
e2
)
const
{
return
(
e1
->
getMinVertex
()
==
e2
->
getMinVertex
()
&&
e1
->
getMaxVertex
()
==
e2
->
getMaxVertex
());
}
};
struct
Less_Edge
:
public
std
::
binary_function
<
MEdge
,
MEdge
,
bool
>
{
bool
operator
()(
const
MEdge
&
e1
,
const
MEdge
&
e2
)
const
{
if
(
e1
.
getMinVertex
()
<
e2
.
getMinVertex
())
return
true
;
if
(
e1
.
getMinVertex
()
>
e2
.
getMinVertex
())
return
false
;
if
(
e1
.
getMaxVertex
()
<
e2
.
getMaxVertex
())
return
true
;
return
false
;
}
};
struct
Less_EdgePtr
:
public
std
::
binary_function
<
MEdge
*
,
MEdge
*
,
bool
>
{
bool
operator
()(
const
MEdge
*
const
e1
,
const
MEdge
*
const
e2
)
const
{
if
(
e1
->
getMinVertex
()
<
e2
->
getMinVertex
())
return
true
;
if
(
e1
->
getMinVertex
()
>
e2
->
getMinVertex
())
return
false
;
if
(
e1
->
getMaxVertex
()
<
e2
->
getMaxVertex
())
return
true
;
return
false
;
}
};
struct
Hash_Edge
:
public
std
::
unary_function
<
MEdge
,
size_t
>
{
size_t
operator
()(
const
MEdge
&
e
)
const
{
const
MVertex
*
v
[
2
];
v
[
0
]
=
e
.
getMinVertex
();
v
[
1
]
=
e
.
getMaxVertex
();
return
HashFNV1a
<
sizeof
(
MVertex
*
[
2
])
>::
eval
(
v
);
}
};
struct
Hash_EdgePtr
:
public
std
::
unary_function
<
MEdge
*
,
size_t
>
{
size_t
operator
()(
const
MEdge
*
const
e
)
const
{
const
MVertex
*
v
[
2
];
v
[
0
]
=
e
->
getMinVertex
();
v
[
1
]
=
e
->
getMaxVertex
();
return
HashFNV1a
<
sizeof
(
MVertex
*
[
2
])
>::
eval
(
v
);
}
};
#endif
#endif
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