Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
integration-cfmesh
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Community
integration-cfmesh
Commits
8fdc373b
Commit
8fdc373b
authored
Jun 30, 2014
by
Franjo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented merging of a surface as a subset into the master surface
parent
e207f739
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
443 additions
and
0 deletions
+443
-0
meshLibrary/Make/files
meshLibrary/Make/files
+3
-0
meshLibrary/utilities/triSurfaceTools/triSurfaceImportSurfaceAsSubset/triSurfaceImportSurfaceAsSubset.C
...ceImportSurfaceAsSubset/triSurfaceImportSurfaceAsSubset.C
+240
-0
meshLibrary/utilities/triSurfaceTools/triSurfaceImportSurfaceAsSubset/triSurfaceImportSurfaceAsSubset.H
...ceImportSurfaceAsSubset/triSurfaceImportSurfaceAsSubset.H
+103
-0
utilities/importSurfaceAsSubset/Make/files
utilities/importSurfaceAsSubset/Make/files
+3
-0
utilities/importSurfaceAsSubset/Make/options
utilities/importSurfaceAsSubset/Make/options
+10
-0
utilities/importSurfaceAsSubset/importSurfaceAsSubset.C
utilities/importSurfaceAsSubset/importSurfaceAsSubset.C
+84
-0
No files found.
meshLibrary/Make/files
View file @
8fdc373b
...
...
@@ -87,6 +87,7 @@ triSurfaceDetectMaterials = $(triSurfaceTools)/triSurfaceDetectMaterials
triSurfaceDetectPlanarRegions = $(triSurfaceTools)/triSurfaceDetectPlanarRegions
triSurfaceDetectFeatureEdges = $(triSurfaceTools)/triSurfaceDetectFeatureEdges
triSurfaceClassifyEdges = $(triSurfaceTools)/triSurfaceClassifyEdges
triSurfaceImportSurfaceAsSubset = $(triSurfaceTools)/triSurfaceImportSurfaceAsSubset
triSurfacePatchManipulator = $(triSurfaceTools)/triSurfacePatchManipulator
triSurfaceRemoveFacets = $(triSurfaceTools)/triSurfaceRemoveFacets
triSurfaceExtrude2DEdges = $(triSurfaceTools)/triSurfaceExtrude2DEdges
...
...
@@ -454,6 +455,8 @@ $(triSurfaceDetectFeatureEdges)/triSurfaceDetectFeatureEdgesFunctions.C
$(triSurfaceClassifyEdges)/triSurfaceClassifyEdges.C
$(triSurfaceClassifyEdges)/triSurfaceClassifyEdgesFunctions.C
$(triSurfaceImportSurfaceAsSubset)/triSurfaceImportSurfaceAsSubset.C
$(triSurfacePatchManipulator)/triSurfacePatchManipulator.C
$(triSurfacePatchManipulator)/triSurfacePatchManipulatorFunctions.C
...
...
meshLibrary/utilities/triSurfaceTools/triSurfaceImportSurfaceAsSubset/triSurfaceImportSurfaceAsSubset.C
0 → 100644
View file @
8fdc373b
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
cfMesh is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "triSurfaceImportSurfaceAsSubset.H"
#include "meshOctree.H"
#include "meshOctreeCreator.H"
#include "helperFunctions.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void
triSurfaceImportSurfaceAsSubset
::
createOctree
(
const
triSurf
&
surf
,
meshOctree
&
octree
)
{
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
triSurfaceImportSurfaceAsSubset
::
triSurfaceImportSurfaceAsSubset
(
triSurf
&
surface
)
:
surf_
(
surface
),
octreePtr_
(
NULL
)
{}
triSurfaceImportSurfaceAsSubset
::~
triSurfaceImportSurfaceAsSubset
()
{
deleteDemandDrivenData
(
octreePtr_
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void
triSurfaceImportSurfaceAsSubset
::
addSurfaceAsSubset
(
const
triSurf
&
importSurf
,
const
word
&
subsetName
,
const
scalar
angleTol
)
{
if
(
!
octreePtr_
)
{
octreePtr_
=
new
meshOctree
(
surf_
);
meshOctreeCreator
(
*
octreePtr_
).
createOctreeWithRefinedBoundary
(
direction
(
20
),
15
);
}
const
pointField
&
points
=
surf_
.
points
();
const
vectorField
&
fNornals
=
surf_
.
facetNormals
();
const
vectorField
&
fCentres
=
surf_
.
facetCentres
();
labelList
nearestTriangle
(
importSurf
.
size
(),
-
1
);
//- check which triangles in the surface fit best to the centres of the
//- triangles in the import surface
const
pointField
&
importSurfPoints
=
importSurf
.
points
();
const
vectorField
&
importFaceCentres
=
importSurf
.
facetCentres
();
const
vectorField
&
importFaceNormals
=
importSurf
.
facetNormals
();
# ifdef USE_OMP
# pragma omp parallel for schedule(dynamic, 40)
# endif
forAll
(
nearestTriangle
,
triI
)
{
point
np
;
scalar
dSq
;
label
nt
,
patch
;
octreePtr_
->
findNearestSurfacePoint
(
np
,
dSq
,
nt
,
patch
,
importFaceCentres
[
triI
]
);
//- find the longest edge distance
scalar
maxEdgeDSq
(
0
.);
const
labelledTri
&
tri
=
importSurf
[
triI
];
forAll
(
tri
,
pI
)
{
const
point
&
s
=
importSurfPoints
[
tri
[
pI
]];
const
point
&
e
=
importSurfPoints
[
tri
[(
pI
+
1
)
%
3
]];
maxEdgeDSq
=
max
(
maxEdgeDSq
,
magSqr
(
e
-
s
));
}
//- check if the triangle has been found
if
(
(
nt
<
0
)
||
(
dSq
>
0
.
09
*
maxEdgeDSq
)
)
{
Warning
<<
"Could not find a matching triangle "
<<
endl
;
Warning
<<
"It seems that your surface meshes do not overlap"
<<
endl
;
continue
;
}
vector
nTri
=
importFaceNormals
[
triI
];
const
scalar
magSqrTri
=
magSqr
(
nTri
);
//- skip sliver triangles
if
(
magSqrTri
<
VSMALL
)
continue
;
vector
normal
=
fNornals
[
nt
];
const
scalar
dSqNormal
=
magSqr
(
normal
);
//- skip sliver triangles
if
(
dSqNormal
<
VSMALL
)
continue
;
if
(
((
nTri
&
normal
)
/
(
magSqrTri
*
dSqNormal
))
>
angleTol
)
nearestTriangle
[
triI
]
=
nt
;
}
meshOctree
otherSurfOctree
(
importSurf
);
meshOctreeCreator
(
otherSurfOctree
).
createOctreeWithRefinedBoundary
(
20
,
15
);
//- search for nearest facets in the import surface
DynList
<
label
>
containedTriangles
;
# ifdef USE_OMP
# pragma omp parallel for schedule(dynamic, 40) private(containedTriangles)
# endif
forAll
(
surf_
,
triI
)
{
//- find the bounding box and the ize of the triangle
boundBox
bb
(
fCentres
[
triI
],
fCentres
[
triI
]);
scalar
maxEdgeDSq
(
0
.);
const
labelledTri
&
tri
=
surf_
[
triI
];
forAll
(
tri
,
pI
)
{
//- bounding box of the surface triangle
bb
.
min
()
=
min
(
bb
.
min
(),
points
[
tri
[
pI
]]);
bb
.
max
()
=
max
(
bb
.
max
(),
points
[
tri
[
pI
]]);
const
point
&
s
=
points
[
tri
[
pI
]];
const
point
&
e
=
points
[
tri
[(
pI
+
1
)
%
3
]];
maxEdgeDSq
=
max
(
maxEdgeDSq
,
magSqr
(
e
-
s
));
}
//- find the nearest triangle in the surface which shall be imported
otherSurfOctree
.
findTrianglesInBox
(
bb
,
containedTriangles
);
label
nt
(
-
1
);
scalar
dSq
(
VGREAT
);
forAll
(
containedTriangles
,
ctI
)
{
const
point
p
=
help
::
nearestPointOnTheTriangle
(
containedTriangles
[
ctI
],
importSurf
,
fCentres
[
triI
]
);
const
scalar
distSq
=
magSqr
(
p
-
fCentres
[
triI
]);
if
(
distSq
<
dSq
)
{
nt
=
containedTriangles
[
ctI
];
dSq
=
distSq
;
}
}
//- check if the triangle has been found
if
(
(
nt
<
0
)
||
(
dSq
>
0
.
09
*
maxEdgeDSq
)
)
continue
;
//- skip firther checkes f it has found the same triangle
if
(
nearestTriangle
[
nt
]
==
triI
)
continue
;
vector
nTri
=
fNornals
[
triI
];
const
scalar
magSqrTri
=
magSqr
(
nTri
);
//- skip sliver triangles
if
(
magSqrTri
<
VSMALL
)
continue
;
vector
normal
=
importFaceNormals
[
nt
];
const
scalar
dSqNormal
=
magSqr
(
normal
);
//- skip sliver triangles
if
(
dSqNormal
<
VSMALL
)
continue
;
if
(
((
nTri
&
normal
)
/
(
magSqrTri
*
dSqNormal
))
>
angleTol
)
nearestTriangle
[
nt
]
=
triI
;
}
//- create a facet subset in the surface mesh and add the facets into it
const
label
subsetId
=
surf_
.
addFacetSubset
(
subsetName
);
forAll
(
nearestTriangle
,
triI
)
{
if
(
nearestTriangle
[
triI
]
<
0
)
continue
;
surf_
.
addFacetToSubset
(
subsetId
,
nearestTriangle
[
triI
]);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// ************************************************************************* //
meshLibrary/utilities/triSurfaceTools/triSurfaceImportSurfaceAsSubset/triSurfaceImportSurfaceAsSubset.H
0 → 100644
View file @
8fdc373b
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
cfMesh is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
triSurfaceImportSurfaceAsSubset
Description
Creates a subset in the master surface consisting of facets which are
near the other surface
SourceFiles
triSurfaceImportSurfaceAsSubset.C
\*---------------------------------------------------------------------------*/
#ifndef triSurfaceImportSurfaceAsSubset_H
#define triSurfaceImportSurfaceAsSubset_H
#include "triSurf.H"
#include "boolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
class
meshOctree
;
/*---------------------------------------------------------------------------*\
Class triSurfaceImportSurfaceAsSubset Declaration
\*---------------------------------------------------------------------------*/
class
triSurfaceImportSurfaceAsSubset
{
// Private data
//- reference to triSurf
triSurf
&
surf_
;
//- pointer to meshOctree, needed for searching on the master surface
meshOctree
*
octreePtr_
;
// Private member functions
void
createOctree
(
const
triSurf
&
,
meshOctree
&
);
//- Disallow default bitwise copy construct
triSurfaceImportSurfaceAsSubset
(
const
triSurfaceImportSurfaceAsSubset
&
);
//- Disallow default bitwise assignment
void
operator
=
(
const
triSurfaceImportSurfaceAsSubset
&
);
public:
// Constructors
//- Construct from triSurf
triSurfaceImportSurfaceAsSubset
(
triSurf
&
surface
);
// Destructor
~
triSurfaceImportSurfaceAsSubset
();
// Member Functions
//- finds the nearest faces in the surface to the import surf
//- and creates a subset
void
addSurfaceAsSubset
(
const
triSurf
&
importSurf
,
const
word
&
subsetName
,
const
scalar
angleTol
=
5.
*
M_PI
/
180.
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
utilities/importSurfaceAsSubset/Make/files
0 → 100644
View file @
8fdc373b
importSurfaceAsSubset.C
EXE = $(FOAM_USER_APPBIN)/importSurfaceAsSubset
utilities/importSurfaceAsSubset/Make/options
0 → 100644
View file @
8fdc373b
EXE_INC = \
-I../../meshLibrary/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-ltriSurface \
-L$(FOAM_USER_LIBBIN) \
-lmeshLibrary \
-lmeshTools
utilities/importSurfaceAsSubset/importSurfaceAsSubset.C
0 → 100644
View file @
8fdc373b
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | cfMesh: A library for mesh generation
\\ / O peration |
\\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
\\/ M anipulation | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
cfMesh is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Description
Finds feature edges and corners of a triangulated surface
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IFstream.H"
#include "fileName.H"
#include "triSurf.H"
#include "OFstream.H"
#include "OSspecific.H"
#include "demandDrivenData.H"
#include "triSurfaceImportSurfaceAsSubset.H"
#include <cstdlib>
#include <sstream>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
using
namespace
Foam
;
int
main
(
int
argc
,
char
*
argv
[])
{
argList
::
noParallel
();
argList
::
validArgs
.
clear
();
argList
::
validArgs
.
append
(
"master surface file"
);
argList
::
validArgs
.
append
(
"import surface file"
);
argList
args
(
argc
,
argv
);
fileName
inFileName
(
args
.
args
()[
1
]);
fileName
importFileName
(
args
.
args
()[
2
]);
triSurf
originalSurface
(
inFileName
);
triSurf
importedSurface
(
importFileName
);
triSurfaceImportSurfaceAsSubset
importSurf
(
originalSurface
);
importSurf
.
addSurfaceAsSubset
(
importedSurface
,
importFileName
.
lessExt
());
if
(
inFileName
.
ext
()
==
"fms"
)
{
originalSurface
.
writeSurface
(
inFileName
);
}
else
{
fileName
newName
=
inFileName
.
lessExt
();
newName
.
append
(
".fms"
);
Warning
<<
"Writting surface as "
<<
newName
<<
" to preserve the subset!!"
<<
endl
;
originalSurface
.
writeSurface
(
newName
);
}
Info
<<
"End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment