diff --git a/applications/utilities/surface/surfaceAutoPatch/Make/files b/applications/utilities/surface/surfaceAutoPatch/Make/files
deleted file mode 100644
index 38a0ebbbf2..0000000000
--- a/applications/utilities/surface/surfaceAutoPatch/Make/files
+++ /dev/null
@@ -1,3 +0,0 @@
-surfaceAutoPatch.C
-
-EXE = $(FOAM_APPBIN)/surfaceAutoPatch
diff --git a/applications/utilities/surface/surfaceAutoPatch/Make/options b/applications/utilities/surface/surfaceAutoPatch/Make/options
deleted file mode 100644
index 9f08e8d2a8..0000000000
--- a/applications/utilities/surface/surfaceAutoPatch/Make/options
+++ /dev/null
@@ -1,7 +0,0 @@
-EXE_INC = \
- -I$(LIB_SRC)/meshTools/lnInclude \
- -I$(LIB_SRC)/triSurface/lnInclude
-
-EXE_LIBS = \
- -lmeshTools \
- -ltriSurface
diff --git a/applications/utilities/surface/surfaceAutoPatch/surfaceAutoPatch.C b/applications/utilities/surface/surfaceAutoPatch/surfaceAutoPatch.C
deleted file mode 100644
index f53ec82963..0000000000
--- a/applications/utilities/surface/surfaceAutoPatch/surfaceAutoPatch.C
+++ /dev/null
@@ -1,125 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
- \\/ M anipulation |
--------------------------------------------------------------------------------
-License
- This file is part of OpenFOAM.
-
- OpenFOAM 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.
-
- OpenFOAM 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 OpenFOAM. If not, see .
-
-Application
- surfaceAutoPatch
-
-Description
- Patches surface according to feature angle. Like autoPatch.
-
-\*---------------------------------------------------------------------------*/
-
-#include "triangle.H"
-#include "triSurface.H"
-#include "argList.H"
-#include "surfaceFeatures.H"
-#include "treeBoundBox.H"
-#include "meshTools.H"
-#include "OFstream.H"
-
-using namespace Foam;
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-
-int main(int argc, char *argv[])
-{
- argList::noParallel();
- argList::validArgs.append("input surfaceFile");
- argList::validArgs.append("output surfaceFile");
- argList::validArgs.append("includedAngle [0..180]");
- argList args(argc, argv);
-
- const fileName inFileName = args[1];
- const fileName outFileName = args[2];
- const scalar includedAngle = args.argRead(3);
-
- Info<< "Surface : " << inFileName << nl << endl;
-
-
- // Read
- // ~~~~
-
- Info<< "Reading : " << inFileName << endl;
- triSurface surf(inFileName);
-
- Info<< "Read surface:" << endl;
- surf.writeStats(Info);
- Info<< endl;
-
-
-
- // Construct features from surface&featureangle
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- Info<< "Constructing feature set from included angle " << includedAngle
- << endl;
-
- surfaceFeatures set(surf, includedAngle);
-
- Info<< nl
- << "Feature set:" << nl
- << " feature points : " << set.featurePoints().size() << nl
- << " feature edges : " << set.featureEdges().size() << nl
- << " of which" << nl
- << " region edges : " << set.nRegionEdges() << nl
- << " external edges : " << set.nExternalEdges() << nl
- << " internal edges : " << set.nInternalEdges() << nl
- << endl;
-
- // Get per-edge status.
- boolList borderEdge(surf.nEdges(), false);
- forAll(set.featureEdges(), i)
- {
- borderEdge[set.featureEdges()[i]] = true;
- }
-
- labelList faceRegion(surf.size());
- label nRegions = surf.markZones(borderEdge, faceRegion);
-
- // Reregion triangles.
- forAll(surf, i)
- {
- surf[i].region() = faceRegion[i];
- }
-
- // Create some patches
- surf.patches().setSize(nRegions);
-
- forAll(surf.patches(), patchI)
- {
- surf.patches()[patchI].name() = "patch" + Foam::name(patchI);
- surf.patches()[patchI].geometricType() = "empty";
- }
-
-
- Info<< "Writing : " << outFileName << endl;
- surf.write(outFileName, true);
-
- Info<< "End\n" << endl;
-
- return 0;
-}
-
-
-// ************************************************************************* //
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/Allwmake b/applications/utilities/surface/surfaceBooleanFeatures/Allwmake
new file mode 100755
index 0000000000..50d640f2b2
--- /dev/null
+++ b/applications/utilities/surface/surfaceBooleanFeatures/Allwmake
@@ -0,0 +1,15 @@
+#!/bin/sh
+cd ${0%/*} || exit 1 # Run from this directory
+set -x
+
+if [ -z "$CGAL_ARCH_PATH" ]
+then
+ export COMPILE_FLAGS="-DNO_CGAL"
+else
+ wmake PolyhedronReader
+ export COMPILE_FLAGS='-IPolyhedronReader'
+ export LINK_FLAGS='${CGAL_LIBS} -lPolyhedronReader'
+fi
+wmake
+
+# ----------------------------------------------------------------- end-of-file
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/CGAL3DKernel.H b/applications/utilities/surface/surfaceBooleanFeatures/CGAL3DKernel.H
new file mode 100644
index 0000000000..e753060ce0
--- /dev/null
+++ b/applications/utilities/surface/surfaceBooleanFeatures/CGAL3DKernel.H
@@ -0,0 +1,55 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
+ \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM 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.
+
+ OpenFOAM 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 OpenFOAM. If not, see .
+
+Typedefs
+ CGAL3DKernel
+
+Description
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef CGAL3DKernel_H
+#define CGAL3DKernel_H
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef CGAL_INEXACT
+
+ // Fast kernel using a double as the storage type
+ #include "CGAL/Exact_predicates_inexact_constructions_kernel.h"
+ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
+
+#else
+
+ // Very robust but expensive kernel
+ #include "CGAL/Exact_predicates_exact_constructions_kernel.h"
+ typedef CGAL::Exact_predicates_exact_constructions_kernel K;
+
+#endif
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H b/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H
new file mode 100644
index 0000000000..0eba1bee2f
--- /dev/null
+++ b/applications/utilities/surface/surfaceBooleanFeatures/CGALIndexedPolyhedron.H
@@ -0,0 +1,98 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
+ \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM 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.
+
+ OpenFOAM 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 OpenFOAM. If not, see .
+
+Typedefs
+ IndexedPolyhedron
+
+Description
+ CGAL data structures used for triSurface handling
+
+ Define CGAL_INEXACT to use Exact_predicates_inexact_constructions kernel
+ otherwise the more robust but much less efficient
+ Exact_predicates_exact_constructions will be used.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef IndexedPolyhedron_H
+#define IndexedPolyhedron_H
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+// Include uint.H before CGAL headers to define __STDC_LIMIT_MACROS
+#include "uint.H"
+
+#include "CGAL3DKernel.H"
+#include
+#include
+
+#include "label.H"
+
+
+typedef CGAL::Point_3 Point;
+typedef CGAL::Segment_3 Segment;
+typedef CGAL::Direction_3 Direction;
+typedef CGAL::Plane_3 Plane;
+typedef CGAL::Triangle_3 Triangle;
+
+// Define new class with color and define the polyhedron types
+template
+struct IndexedFace
+:
+ public CGAL::HalfedgeDS_face_base
+{
+ Foam::label index;
+ Foam::label region;
+};
+struct My_items
+:
+ public CGAL::Polyhedron_items_3
+{
+ template
+ struct Face_wrapper
+ {
+ typedef IndexedFace Face;
+ };
+};
+
+
+//typedef CGAL::Polyhedron_3 Polyhedron;
+typedef CGAL::Polyhedron_3 Polyhedron;
+
+typedef Polyhedron::HalfedgeDS HalfedgeDS;
+typedef Polyhedron::Edge_iterator Edge_iterator;
+typedef Polyhedron::Vertex Vertex;
+typedef Polyhedron::Vertex_iterator Vertex_iterator;
+typedef Polyhedron::Halfedge_handle Halfedge_handle;
+typedef Polyhedron::Edge_iterator Edge_iterator;
+typedef Polyhedron::Facet_iterator Facet_iterator;
+typedef Polyhedron::Halfedge_around_facet_const_circulator HFCC;
+typedef Polyhedron::Vertex_const_iterator VCI;
+
+typedef CGAL::Nef_polyhedron_3 Nef_polyhedron;
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/Make/options b/applications/utilities/surface/surfaceBooleanFeatures/Make/options
index 727dbd1c2b..ed05fef039 100644
--- a/applications/utilities/surface/surfaceBooleanFeatures/Make/options
+++ b/applications/utilities/surface/surfaceBooleanFeatures/Make/options
@@ -1,9 +1,29 @@
+EXE_NDEBUG = -DNDEBUG
+/* EXE_NDEBUG = -g -O0 -DFULLDEBUG */
+
+
+c++CGALWARN = -Wno-old-style-cast
+
+/*-- Define NO_CGAL to avoid using CGAL altogether */
+/*-- Define CGAL_INEXACT to use inexact CGAL constructions */
+
+include $(GENERAL_RULES)/CGAL
+
EXE_INC = \
- -I$(LIB_SRC)/triSurface/lnInclude \
+ ${ROUNDING_MATH} \
+ ${EXE_NDEBUG} \
+ ${CGAL_INC} \
+ ${c++CGALWARN} \
+ $(COMPILE_FLAGS) \
+ -IPolyhedronReader \
+ -I$(FOAM_SRC)/surfMesh/lnInclude \
+ -I$(FOAM_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
+ -lsurfMesh \
-ltriSurface \
-ledgeMesh \
- -lmeshTools
+ -lmeshTools \
+ $(LINK_FLAGS)
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/Make/files b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/Make/files
new file mode 100644
index 0000000000..d0e01d2747
--- /dev/null
+++ b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/Make/files
@@ -0,0 +1,3 @@
+PolyhedronReader.C
+
+LIB = $(FOAM_LIBBIN)/libPolyhedronReader
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/Make/options b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/Make/options
new file mode 100644
index 0000000000..6603adda0f
--- /dev/null
+++ b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/Make/options
@@ -0,0 +1,25 @@
+EXE_NDEBUG = -DNDEBUG
+/* EXE_NDEBUG = -g -O0 -DFULLDEBUG */
+
+
+c++CGALWARN = -Wno-old-style-cast
+
+/*-- Define CGAL_INEXACT to use inexact CGAL constructions */
+
+include $(GENERAL_RULES)/CGAL
+
+EXE_INC = \
+ ${ROUNDING_MATH} \
+ ${EXE_NDEBUG} \
+ ${CGAL_INC} \
+ ${c++CGALWARN} \
+ -I.. \
+ -I$(FOAM_SRC)/surfMesh/lnInclude \
+ -I$(FOAM_SRC)/triSurface/lnInclude \
+ -I$(LIB_SRC)/edgeMesh/lnInclude \
+ -I$(LIB_SRC)/meshTools/lnInclude \
+ -I/usr/include/Qt
+
+LIB_LIBS = \
+ -L${CGAL_ARCH_PATH}/lib \
+ -ltriSurface
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/PolyhedronReader.C b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/PolyhedronReader.C
new file mode 100644
index 0000000000..462b9a6f05
--- /dev/null
+++ b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/PolyhedronReader.C
@@ -0,0 +1,49 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
+ \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM 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.
+
+ OpenFOAM 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 OpenFOAM. If not, see .
+
+\*---------------------------------------------------------------------------*/
+
+#include "PolyhedronReader.H"
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::PolyhedronReader::PolyhedronReader(const triSurface& s, Polyhedron& p)
+{
+ Build_triangle triangle(s);
+ p.delegate(triangle);
+ // Populate index and region
+ Foam::label nTris = 0;
+ for
+ (
+ Facet_iterator fi = p.facets_begin();
+ fi != p.facets_end();
+ ++fi
+ )
+ {
+ fi->index = nTris++;
+ fi->region = s[fi->index].region();
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/PolyhedronReader.H b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/PolyhedronReader.H
new file mode 100644
index 0000000000..ef3e88a0ac
--- /dev/null
+++ b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/PolyhedronReader.H
@@ -0,0 +1,101 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
+ \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM 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.
+
+ OpenFOAM 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 OpenFOAM. If not, see .
+
+Class
+ Foam::PolyhedronReader
+
+Description
+
+SourceFiles
+ PolyhedronReader.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef PolyhedronReader_H
+#define PolyhedronReader_H
+
+#include "CGALIndexedPolyhedron.H"
+#include "triSurface.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+ Class PolyhedronReader Declaration
+\*---------------------------------------------------------------------------*/
+
+class PolyhedronReader
+{
+ // Private Classes
+
+ template
+ class Build_triangle
+ :
+ public CGAL::Modifier_base
+ {
+ const triSurface& s_;
+
+ public:
+
+ Build_triangle(const triSurface& s);
+
+ void operator()(HDS& hds);
+ };
+
+
+ // Private Member Functions
+
+ //- Disallow default bitwise copy construct
+ PolyhedronReader(const PolyhedronReader&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const PolyhedronReader&);
+
+
+public:
+
+ // Constructors
+
+ //- Populate polyhedron from surface
+ PolyhedronReader(const triSurface& s, Polyhedron& p);
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef NoRepository
+# include "PolyhedronReaderTemplates.C"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/PolyhedronReaderTemplates.C b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/PolyhedronReaderTemplates.C
new file mode 100644
index 0000000000..53ea3b1b87
--- /dev/null
+++ b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/PolyhedronReaderTemplates.C
@@ -0,0 +1,72 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
+ \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM 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.
+
+ OpenFOAM 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 OpenFOAM. If not, see .
+
+\*---------------------------------------------------------------------------*/
+
+#include "PolyhedronReader.H"
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+template
+Foam::PolyhedronReader::Build_triangle::Build_triangle
+(
+ const triSurface& s
+)
+:
+ s_(s)
+{}
+
+
+// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
+
+template
+void Foam::PolyhedronReader::Build_triangle::operator()(HDS& hds)
+{
+ // Postcondition: hds is a valid polyhedral surface.
+ CGAL::Polyhedron_incremental_builder_3 B(hds, true);
+
+ B.begin_surface(s_.nPoints(), s_.size());
+
+ typedef typename HDS::Vertex Vertex;
+ typedef typename Vertex::Point Point;
+
+ const Foam::pointField& pts = s_.points();
+ forAll(pts, i)
+ {
+ const Foam::point& pt = pts[i];
+ B.add_vertex(Point(pt.x(), pt.y(), pt.z()));
+ }
+ forAll(s_, i)
+ {
+ const Foam::labelledTri& t = s_[i];
+ B.begin_facet();
+ B.add_vertex_to_facet(t[0]);
+ B.add_vertex_to_facet(t[1]);
+ B.add_vertex_to_facet(t[2]);
+ B.end_facet();
+ }
+ B.end_surface();
+}
+
+
+// ************************************************************************* //
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C
index 6c4e67dd7d..e948cd1fdb 100644
--- a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C
+++ b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
- \\/ M anipulation |
+ \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -74,11 +74,34 @@ Description
#include "featureEdgeMesh.H"
#include "extendedFeatureEdgeMesh.H"
#include "triSurfaceSearch.H"
+#include "triSurfaceMesh.H"
#include "OFstream.H"
+#include "OBJstream.H"
#include "booleanSurface.H"
#include "edgeIntersections.H"
#include "meshTools.H"
-#include "labelPair.H"
+#include "DynamicField.H"
+
+
+#ifndef NO_CGAL
+
+#include
+#include
+#include
+#include "CGALIndexedPolyhedron.H"
+#include "PolyhedronReader.H"
+typedef CGAL::AABB_face_graph_triangle_primitive
+<
+ Polyhedron, CGAL::Default, CGAL::Tag_false
+> Primitive;
+typedef CGAL::AABB_traits Traits;
+typedef CGAL::AABB_tree Tree;
+
+typedef boost::optional::Type >
+Segment_intersection;
+
+#endif // NO_CGAL
+
using namespace Foam;
@@ -105,7 +128,7 @@ bool intersectSurfaces
scalarField surfPointTol
(
- 1e-3*edgeIntersections::minEdgeLength(surf)
+ max(1e-3*edgeIntersections::minEdgeLength(surf), SMALL)
);
// Determine raw intersections
@@ -178,7 +201,7 @@ bool intersectSurfaces
scalarField surf1PointTol
(
- 1e-3*edgeIntersections::minEdgeLength(surf1)
+ max(1e-3*edgeIntersections::minEdgeLength(surf1), SMALL)
);
// Determine raw intersections
@@ -221,7 +244,7 @@ bool intersectSurfaces
scalarField surf2PointTol
(
- 1e-3*edgeIntersections::minEdgeLength(surf2)
+ max(1e-3*edgeIntersections::minEdgeLength(surf2), SMALL)
);
// Determine raw intersections
@@ -311,8 +334,8 @@ void calcEdgeCuts
triSurface& surf1,
triSurface& surf2,
const bool perturb,
- edgeIntersections& edge1Cuts,
- edgeIntersections& edge2Cuts
+ edgeIntersections& edgeCuts1,
+ edgeIntersections& edgeCuts2
)
{
if (perturb)
@@ -320,9 +343,9 @@ void calcEdgeCuts
intersectSurfaces
(
surf1,
- edge1Cuts,
+ edgeCuts1,
surf2,
- edge2Cuts
+ edgeCuts2
);
}
else
@@ -332,11 +355,11 @@ void calcEdgeCuts
Info<< "Determining intersections of surf1 edges with surf2 faces"
<< endl;
- edge1Cuts = edgeIntersections
+ edgeCuts1 = edgeIntersections
(
surf1,
querySurf2,
- 1e-3*edgeIntersections::minEdgeLength(surf1)
+ max(1e-3*edgeIntersections::minEdgeLength(surf1), SMALL)
);
triSurfaceSearch querySurf1(surf1);
@@ -344,161 +367,875 @@ void calcEdgeCuts
Info<< "Determining intersections of surf2 edges with surf1 faces"
<< endl;
- edge2Cuts = edgeIntersections
+ edgeCuts2 = edgeIntersections
(
surf2,
querySurf1,
- 1e-3*edgeIntersections::minEdgeLength(surf2)
+ max(1e-3*edgeIntersections::minEdgeLength(surf2), SMALL)
);
}
}
-void calcFeaturePoints(const pointField& points, const edgeList& edges)
+// CGAL variants
+
+#ifndef NO_CGAL
+
+void visitPointRegion
+(
+ const triSurface& s,
+ const label zoneI,
+ const label pointI,
+ const label startEdgeI,
+ const label startFaceI,
+ labelList& pFacesZone
+)
{
- edgeMesh eMesh(points, edges);
+ const labelList& eFaces = s.edgeFaces()[startEdgeI];
- const labelListList& pointEdges = eMesh.pointEdges();
-
- // Get total number of feature points
- label nFeaturePoints = 0;
- forAll(pointEdges, pI)
+ if (eFaces.size() == 2)
{
- const labelList& pEdges = pointEdges[pI];
-
- if (pEdges.size() == 1)
+ label nextFaceI;
+ if (eFaces[0] == startFaceI)
{
- nFeaturePoints++;
+ nextFaceI = eFaces[1];
}
- }
-
-
- // Calculate addressing from feature point to cut point and cut edge
- labelList featurePointToCutPoint(nFeaturePoints);
- labelList featurePointToCutEdge(nFeaturePoints);
-
- label nFeatPts = 0;
- forAll(pointEdges, pI)
- {
- const labelList& pEdges = pointEdges[pI];
-
- if (pEdges.size() == 1)
+ else if (eFaces[1] == startFaceI)
{
- featurePointToCutPoint[nFeatPts] = pI;
- featurePointToCutEdge[nFeatPts] = pEdges[0];
- nFeatPts++;
+ nextFaceI = eFaces[0];
+ }
+ else
+ {
+ FatalErrorIn("visitPointRegion(..)")
+ << "problem" << exit(FatalError);
+ nextFaceI = -1;
+ }
+
+
+
+ label index = findIndex(s.pointFaces()[pointI], nextFaceI);
+
+ if (pFacesZone[index] == -1)
+ {
+ // Mark face as been visited.
+ pFacesZone[index] = zoneI;
+
+ // Step to next edge on face which is still using pointI
+ const labelList& fEdges = s.faceEdges()[nextFaceI];
+
+ label nextEdgeI = -1;
+
+ forAll(fEdges, i)
+ {
+ label edgeI = fEdges[i];
+ const edge& e = s.edges()[edgeI];
+
+ if (edgeI != startEdgeI && (e[0] == pointI || e[1] == pointI))
+ {
+ nextEdgeI = edgeI;
+
+ break;
+ }
+ }
+
+ if (nextEdgeI == -1)
+ {
+ FatalErrorIn("visitPointRegion()")
+ << "Problem: cannot find edge out of " << fEdges
+ << "on face " << nextFaceI << " that uses point " << pointI
+ << " and is not edge " << startEdgeI << abort(FatalError);
+ }
+
+
+ visitPointRegion
+ (
+ s,
+ zoneI,
+ pointI,
+ nextEdgeI,
+ nextFaceI,
+ pFacesZone
+ );
}
}
}
-int main(int argc, char *argv[])
+label dupNonManifoldPoints(triSurface& s, labelList& pointMap)
{
- argList::noParallel();
- argList::validArgs.append("action");
- argList::validArgs.append("surface file");
- argList::validArgs.append("surface file");
+ const labelListList& pf = s.pointFaces();
+ const labelListList& fe = s.faceEdges();
+ const edgeList& edges = s.edges();
- argList::addBoolOption
- (
- "surf1Baffle",
- "Mark surface 1 as a baffle"
- );
- argList::addBoolOption
- (
- "surf2Baffle",
- "Mark surface 2 as a baffle"
- );
+ DynamicField newPoints(s.points());
+ // From dupSurf back to s.pointa
+ DynamicList