Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wenqing
ogs
Commits
2bbfc352
Commit
2bbfc352
authored
10 years ago
by
Norihiro Watanabe
Browse files
Options
Downloads
Patches
Plain Diff
add convertSurfaceToMesh()
parent
0447d56e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MeshLib/convertMeshToGeo.cpp
+24
-4
24 additions, 4 deletions
MeshLib/convertMeshToGeo.cpp
MeshLib/convertMeshToGeo.h
+11
-0
11 additions, 0 deletions
MeshLib/convertMeshToGeo.h
with
35 additions
and
4 deletions
MeshLib/convertMeshToGeo.cpp
+
24
−
4
View file @
2bbfc352
...
...
@@ -17,15 +17,13 @@
#include
"logog/include/logog.hpp"
#include
"GeoLib/GEOObjects.h"
namespace
GeoLib
{
class
Surface
;
}
#include
"GeoLib/Surface.h"
#include
"Mesh.h"
#include
"Elements/Tri.h"
#include
"Elements/Quad.h"
#include
"MeshInformation.h"
#include
"MeshEditing/MeshRevision.h"
namespace
MeshLib
{
...
...
@@ -81,6 +79,28 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects
return
true
;
}
MeshLib
::
Mesh
*
convertSurfaceToMesh
(
const
GeoLib
::
Surface
&
sfc
,
const
std
::
string
&
mesh_name
,
double
eps
)
{
// convert to a mesh including duplicated nodes
std
::
vector
<
MeshLib
::
Node
*>
nodes
;
std
::
vector
<
MeshLib
::
Element
*>
elements
;
std
::
size_t
nodeId
=
0
;
for
(
std
::
size_t
i
=
0
;
i
<
sfc
.
getNTriangles
();
i
++
)
{
auto
*
tri
=
sfc
[
i
];
MeshLib
::
Node
**
tri_nodes
=
new
MeshLib
::
Node
*
[
3
];
for
(
unsigned
j
=
0
;
j
<
3
;
j
++
)
tri_nodes
[
j
]
=
new
MeshLib
::
Node
(
tri
->
getPoint
(
j
)
->
getCoords
(),
nodeId
++
);
elements
.
push_back
(
new
MeshLib
::
Tri
(
tri_nodes
,
0
,
i
));
for
(
unsigned
j
=
0
;
j
<
3
;
j
++
)
nodes
.
push_back
(
tri_nodes
[
j
]);
}
MeshLib
::
Mesh
mesh_with_duplicated_nodes
(
mesh_name
,
nodes
,
elements
);
// remove duplicated nodes
MeshLib
::
MeshRevision
rev
(
mesh_with_duplicated_nodes
);
return
rev
.
simplifyMesh
(
mesh_with_duplicated_nodes
.
getName
(),
eps
);
}
}
This diff is collapsed.
Click to expand it.
MeshLib/convertMeshToGeo.h
+
11
−
0
View file @
2bbfc352
...
...
@@ -16,10 +16,12 @@
#define CONVERTMESHTOGEO_H_
#include
<limits>
#include
<string>
namespace
GeoLib
{
class
GEOObjects
;
class
Surface
;
}
namespace
MeshLib
...
...
@@ -36,6 +38,15 @@ namespace MeshLib
*/
bool
convertMeshToGeo
(
const
MeshLib
::
Mesh
&
mesh
,
GeoLib
::
GEOObjects
&
geo_objects
,
double
eps
=
std
::
numeric_limits
<
double
>::
epsilon
());
/**
* Converts a surface into a triangular mesh
* @param sfc Surface object
* @param mesh_name New mesh name
* @param eps Minimum distance for nodes not to be collapsed
* @return a pointer to a converted mesh object. nullptr is returned if the conversion fails.
*/
MeshLib
::
Mesh
*
convertSurfaceToMesh
(
const
GeoLib
::
Surface
&
sfc
,
const
std
::
string
&
mesh_name
,
double
eps
=
std
::
numeric_limits
<
double
>::
epsilon
());
}
// namespace
#endif
/* CONVERTMESHTOGEO_H_ */
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