mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -86,11 +86,11 @@ void ControlVolume::calculateCubeFaceStatus(const cvf::Vec3dArray& nodeCoords, d
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename NodeArrayType, typename NodeType, typename IndexType>
|
||||
NodeType quadNormal(ArrayWrapperConst<NodeArrayType, NodeType> nodeCoords, const IndexType cubeFaceIndices[4])
|
||||
template <typename NodeArrayType, typename NodeType, typename IndexType>
|
||||
NodeType quadNormal( ArrayWrapperConst<NodeArrayType, NodeType> nodeCoords, const IndexType cubeFaceIndices[4] )
|
||||
{
|
||||
return (nodeCoords[cubeFaceIndices[2]] - nodeCoords[cubeFaceIndices[0]]) ^
|
||||
(nodeCoords[cubeFaceIndices[3]] - nodeCoords[cubeFaceIndices[1]]);
|
||||
return ( nodeCoords[cubeFaceIndices[2]] - nodeCoords[cubeFaceIndices[0]] ) ^
|
||||
( nodeCoords[cubeFaceIndices[3]] - nodeCoords[cubeFaceIndices[1]] );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -99,7 +99,7 @@ NodeType quadNormal(ArrayWrapperConst<NodeArrayType, NodeType> nodeCoords, const
|
||||
std::vector<cvf::Vec3d> createVertices()
|
||||
{
|
||||
std::vector<cvf::Vec3d> vxs;
|
||||
vxs.resize(14, cvf::Vec3d::ZERO);
|
||||
vxs.resize( 14, cvf::Vec3d::ZERO );
|
||||
|
||||
// clang-format off
|
||||
vxs[ 0]= cvf::Vec3d( 0 , 0 , 0 );
|
||||
@@ -127,7 +127,7 @@ std::vector<std::array<cvf::uint, 4>> getCubeFaces()
|
||||
{
|
||||
std::vector<std::array<cvf::uint, 4>> cubeFaces;
|
||||
|
||||
cubeFaces.resize(4);
|
||||
cubeFaces.resize( 4 );
|
||||
cubeFaces[0] = {0, 1, 2, 3};
|
||||
cubeFaces[1] = {4, 5, 6, 7};
|
||||
cubeFaces[2] = {5, 8, 9, 6};
|
||||
@@ -136,9 +136,9 @@ std::vector<std::array<cvf::uint, 4>> getCubeFaces()
|
||||
return cubeFaces;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, std::vector<cvf::uint> v)
|
||||
std::ostream& operator<<( std::ostream& stream, std::vector<cvf::uint> v )
|
||||
{
|
||||
for (size_t i = 0; i < v.size(); ++i)
|
||||
for ( size_t i = 0; i < v.size(); ++i )
|
||||
{
|
||||
stream << v[i] << " ";
|
||||
}
|
||||
@@ -148,7 +148,7 @@ std::ostream& operator<<(std::ostream& stream, std::vector<cvf::uint> v)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(CellFaceIntersectionTst, Intersection1)
|
||||
TEST( CellFaceIntersectionTst, Intersection1 )
|
||||
{
|
||||
std::vector<cvf::Vec3d> nodes = createVertices();
|
||||
|
||||
@@ -158,117 +158,117 @@ TEST(CellFaceIntersectionTst, Intersection1)
|
||||
auto faces = getCubeFaces();
|
||||
|
||||
EdgeIntersectStorage<cvf::uint> edgeIntersectionStorage;
|
||||
edgeIntersectionStorage.setVertexCount(nodes.size());
|
||||
edgeIntersectionStorage.setVertexCount( nodes.size() );
|
||||
{
|
||||
std::vector<cvf::uint> polygon;
|
||||
bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst(&nodes),
|
||||
faces[0].data(),
|
||||
faces[1].data(),
|
||||
1e-6);
|
||||
bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst( &nodes ),
|
||||
faces[0].data(),
|
||||
faces[1].data(),
|
||||
1e-6 );
|
||||
|
||||
EXPECT_EQ((size_t)5, polygon.size());
|
||||
EXPECT_EQ((size_t)2, additionalVertices.size());
|
||||
EXPECT_TRUE(isOk);
|
||||
overlapPolygons.push_back(polygon);
|
||||
EXPECT_EQ( (size_t)5, polygon.size() );
|
||||
EXPECT_EQ( (size_t)2, additionalVertices.size() );
|
||||
EXPECT_TRUE( isOk );
|
||||
overlapPolygons.push_back( polygon );
|
||||
std::cout << polygon << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<cvf::uint> polygon;
|
||||
bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst(&nodes),
|
||||
faces[0].data(),
|
||||
faces[2].data(),
|
||||
1e-6);
|
||||
bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst( &nodes ),
|
||||
faces[0].data(),
|
||||
faces[2].data(),
|
||||
1e-6 );
|
||||
|
||||
EXPECT_EQ((size_t)5, polygon.size());
|
||||
EXPECT_EQ((size_t)4, additionalVertices.size());
|
||||
EXPECT_TRUE(isOk);
|
||||
overlapPolygons.push_back(polygon);
|
||||
EXPECT_EQ( (size_t)5, polygon.size() );
|
||||
EXPECT_EQ( (size_t)4, additionalVertices.size() );
|
||||
EXPECT_TRUE( isOk );
|
||||
overlapPolygons.push_back( polygon );
|
||||
std::cout << polygon << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<cvf::uint> polygon;
|
||||
bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst(&nodes),
|
||||
faces[0].data(),
|
||||
faces[3].data(),
|
||||
1e-6);
|
||||
bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst( &nodes ),
|
||||
faces[0].data(),
|
||||
faces[3].data(),
|
||||
1e-6 );
|
||||
|
||||
EXPECT_EQ((size_t)3, polygon.size());
|
||||
EXPECT_EQ((size_t)6, additionalVertices.size());
|
||||
EXPECT_TRUE(isOk);
|
||||
overlapPolygons.push_back(polygon);
|
||||
EXPECT_EQ( (size_t)3, polygon.size() );
|
||||
EXPECT_EQ( (size_t)6, additionalVertices.size() );
|
||||
EXPECT_TRUE( isOk );
|
||||
overlapPolygons.push_back( polygon );
|
||||
std::cout << polygon << std::endl;
|
||||
}
|
||||
|
||||
nodes.insert(nodes.end(), additionalVertices.begin(), additionalVertices.end());
|
||||
nodes.insert( nodes.end(), additionalVertices.begin(), additionalVertices.end() );
|
||||
std::vector<cvf::uint> basePolygon;
|
||||
basePolygon.insert(basePolygon.begin(), faces[0].data(), &(faces[0].data()[4]));
|
||||
basePolygon.insert( basePolygon.begin(), faces[0].data(), &( faces[0].data()[4] ) );
|
||||
|
||||
for (cvf::uint vxIdx = 0; vxIdx < nodes.size(); ++vxIdx)
|
||||
for ( cvf::uint vxIdx = 0; vxIdx < nodes.size(); ++vxIdx )
|
||||
{
|
||||
GeometryTools::insertVertexInPolygon(&basePolygon, wrapArrayConst(&nodes), vxIdx, 1e-6);
|
||||
GeometryTools::insertVertexInPolygon( &basePolygon, wrapArrayConst( &nodes ), vxIdx, 1e-6 );
|
||||
}
|
||||
|
||||
EXPECT_EQ((size_t)8, basePolygon.size());
|
||||
EXPECT_EQ( (size_t)8, basePolygon.size() );
|
||||
std::cout << "Bp: " << basePolygon << std::endl;
|
||||
|
||||
for (size_t pIdx = 0; pIdx < overlapPolygons.size(); ++pIdx)
|
||||
for ( size_t pIdx = 0; pIdx < overlapPolygons.size(); ++pIdx )
|
||||
{
|
||||
for (cvf::uint vxIdx = 0; vxIdx < nodes.size(); ++vxIdx)
|
||||
for ( cvf::uint vxIdx = 0; vxIdx < nodes.size(); ++vxIdx )
|
||||
{
|
||||
GeometryTools::insertVertexInPolygon(&overlapPolygons[pIdx], wrapArrayConst(&nodes), vxIdx, 1e-6);
|
||||
GeometryTools::insertVertexInPolygon( &overlapPolygons[pIdx], wrapArrayConst( &nodes ), vxIdx, 1e-6 );
|
||||
}
|
||||
|
||||
if (pIdx == 0)
|
||||
if ( pIdx == 0 )
|
||||
{
|
||||
EXPECT_EQ((size_t)5, overlapPolygons[pIdx].size());
|
||||
EXPECT_EQ( (size_t)5, overlapPolygons[pIdx].size() );
|
||||
}
|
||||
if (pIdx == 1)
|
||||
if ( pIdx == 1 )
|
||||
{
|
||||
EXPECT_EQ((size_t)5, overlapPolygons[pIdx].size());
|
||||
EXPECT_EQ( (size_t)5, overlapPolygons[pIdx].size() );
|
||||
}
|
||||
if (pIdx == 2)
|
||||
if ( pIdx == 2 )
|
||||
{
|
||||
EXPECT_EQ((size_t)4, overlapPolygons[pIdx].size());
|
||||
EXPECT_EQ( (size_t)4, overlapPolygons[pIdx].size() );
|
||||
}
|
||||
|
||||
std::cout << "Op" << pIdx << ":" << overlapPolygons[pIdx] << std::endl;
|
||||
}
|
||||
|
||||
Vec3d normal = quadNormal(wrapArrayConst(&nodes), faces[0].data());
|
||||
Vec3d normal = quadNormal( wrapArrayConst( &nodes ), faces[0].data() );
|
||||
std::vector<bool> faceOverlapPolygonWindingSameAsCubeFaceFlags;
|
||||
faceOverlapPolygonWindingSameAsCubeFaceFlags.resize(overlapPolygons.size(), true);
|
||||
faceOverlapPolygonWindingSameAsCubeFaceFlags.resize( overlapPolygons.size(), true );
|
||||
|
||||
{
|
||||
std::vector<cvf::uint> freeFacePolygon;
|
||||
bool hasHoles = false;
|
||||
|
||||
std::vector<std::vector<cvf::uint>*> overlapPolygonPtrs;
|
||||
for (size_t pIdx = 0; pIdx < overlapPolygons.size(); ++pIdx)
|
||||
for ( size_t pIdx = 0; pIdx < overlapPolygons.size(); ++pIdx )
|
||||
{
|
||||
overlapPolygonPtrs.push_back(&(overlapPolygons[pIdx]));
|
||||
overlapPolygonPtrs.push_back( &( overlapPolygons[pIdx] ) );
|
||||
}
|
||||
|
||||
GeometryTools::calculatePartiallyFreeCubeFacePolygon(wrapArrayConst(&nodes),
|
||||
wrapArrayConst(&basePolygon),
|
||||
normal,
|
||||
overlapPolygonPtrs,
|
||||
faceOverlapPolygonWindingSameAsCubeFaceFlags,
|
||||
&freeFacePolygon,
|
||||
&hasHoles);
|
||||
GeometryTools::calculatePartiallyFreeCubeFacePolygon( wrapArrayConst( &nodes ),
|
||||
wrapArrayConst( &basePolygon ),
|
||||
normal,
|
||||
overlapPolygonPtrs,
|
||||
faceOverlapPolygonWindingSameAsCubeFaceFlags,
|
||||
&freeFacePolygon,
|
||||
&hasHoles );
|
||||
|
||||
EXPECT_EQ((size_t)4, freeFacePolygon.size());
|
||||
EXPECT_FALSE(hasHoles);
|
||||
EXPECT_EQ( (size_t)4, freeFacePolygon.size() );
|
||||
EXPECT_FALSE( hasHoles );
|
||||
std::cout << "FF1: " << freeFacePolygon << std::endl;
|
||||
}
|
||||
|
||||
@@ -277,21 +277,21 @@ TEST(CellFaceIntersectionTst, Intersection1)
|
||||
bool hasHoles = false;
|
||||
|
||||
std::vector<std::vector<cvf::uint>*> overlapPolygonPtrs;
|
||||
for (size_t pIdx = 0; pIdx < 1; ++pIdx)
|
||||
for ( size_t pIdx = 0; pIdx < 1; ++pIdx )
|
||||
{
|
||||
overlapPolygonPtrs.push_back(&(overlapPolygons[pIdx]));
|
||||
overlapPolygonPtrs.push_back( &( overlapPolygons[pIdx] ) );
|
||||
}
|
||||
|
||||
GeometryTools::calculatePartiallyFreeCubeFacePolygon(wrapArrayConst(&nodes),
|
||||
wrapArrayConst(&basePolygon),
|
||||
normal,
|
||||
overlapPolygonPtrs,
|
||||
faceOverlapPolygonWindingSameAsCubeFaceFlags,
|
||||
&freeFacePolygon,
|
||||
&hasHoles);
|
||||
GeometryTools::calculatePartiallyFreeCubeFacePolygon( wrapArrayConst( &nodes ),
|
||||
wrapArrayConst( &basePolygon ),
|
||||
normal,
|
||||
overlapPolygonPtrs,
|
||||
faceOverlapPolygonWindingSameAsCubeFaceFlags,
|
||||
&freeFacePolygon,
|
||||
&hasHoles );
|
||||
|
||||
EXPECT_EQ((size_t)9, freeFacePolygon.size());
|
||||
EXPECT_FALSE(hasHoles);
|
||||
EXPECT_EQ( (size_t)9, freeFacePolygon.size() );
|
||||
EXPECT_FALSE( hasHoles );
|
||||
|
||||
std::cout << "FF2: " << freeFacePolygon << std::endl;
|
||||
}
|
||||
@@ -301,7 +301,7 @@ TEST(CellFaceIntersectionTst, Intersection1)
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
TEST(CellFaceIntersectionTst, Intersection)
|
||||
TEST( CellFaceIntersectionTst, Intersection )
|
||||
{
|
||||
std::vector<cvf::Vec3d> additionalVertices;
|
||||
cvf::Vec3dArray nodes;
|
||||
@@ -311,61 +311,61 @@ TEST(CellFaceIntersectionTst, Intersection)
|
||||
size_t cv1CubeFaceIndices[4] = {0, 1, 2, 3};
|
||||
size_t cv2CubeFaceIndices[4] = {4, 5, 6, 7};
|
||||
|
||||
nodes.resize(8);
|
||||
nodes.setAll(cvf::Vec3d(0, 0, 0));
|
||||
nodes.resize( 8 );
|
||||
nodes.setAll( cvf::Vec3d( 0, 0, 0 ) );
|
||||
EdgeIntersectStorage<size_t> edgeIntersectionStorage;
|
||||
edgeIntersectionStorage.setVertexCount(nodes.size());
|
||||
edgeIntersectionStorage.setVertexCount( nodes.size() );
|
||||
|
||||
// Face 1
|
||||
nodes[0] = cvf::Vec3d(0, 0, 0);
|
||||
nodes[1] = cvf::Vec3d(1, 0, 0);
|
||||
nodes[2] = cvf::Vec3d(1, 1, 0);
|
||||
nodes[3] = cvf::Vec3d(0, 1, 0);
|
||||
nodes[0] = cvf::Vec3d( 0, 0, 0 );
|
||||
nodes[1] = cvf::Vec3d( 1, 0, 0 );
|
||||
nodes[2] = cvf::Vec3d( 1, 1, 0 );
|
||||
nodes[3] = cvf::Vec3d( 0, 1, 0 );
|
||||
// Face 2
|
||||
nodes[4] = cvf::Vec3d(0, 0, 0);
|
||||
nodes[5] = cvf::Vec3d(1, 0, 0);
|
||||
nodes[6] = cvf::Vec3d(1, 1, 0);
|
||||
nodes[7] = cvf::Vec3d(0, 1, 0);
|
||||
nodes[4] = cvf::Vec3d( 0, 0, 0 );
|
||||
nodes[5] = cvf::Vec3d( 1, 0, 0 );
|
||||
nodes[6] = cvf::Vec3d( 1, 1, 0 );
|
||||
nodes[7] = cvf::Vec3d( 0, 1, 0 );
|
||||
|
||||
bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst(&nodes),
|
||||
cv1CubeFaceIndices,
|
||||
cv2CubeFaceIndices,
|
||||
1e-6);
|
||||
EXPECT_EQ((size_t)4, polygon.size());
|
||||
EXPECT_EQ((size_t)0, additionalVertices.size());
|
||||
EXPECT_TRUE(isOk);
|
||||
bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst( &nodes ),
|
||||
cv1CubeFaceIndices,
|
||||
cv2CubeFaceIndices,
|
||||
1e-6 );
|
||||
EXPECT_EQ( (size_t)4, polygon.size() );
|
||||
EXPECT_EQ( (size_t)0, additionalVertices.size() );
|
||||
EXPECT_TRUE( isOk );
|
||||
|
||||
// Face 1
|
||||
nodes[0] = cvf::Vec3d(0, 0, 0);
|
||||
nodes[1] = cvf::Vec3d(1, 0, 0);
|
||||
nodes[2] = cvf::Vec3d(1, 1, 0);
|
||||
nodes[3] = cvf::Vec3d(0, 1, 0);
|
||||
nodes[0] = cvf::Vec3d( 0, 0, 0 );
|
||||
nodes[1] = cvf::Vec3d( 1, 0, 0 );
|
||||
nodes[2] = cvf::Vec3d( 1, 1, 0 );
|
||||
nodes[3] = cvf::Vec3d( 0, 1, 0 );
|
||||
// Face 2
|
||||
nodes[4] = cvf::Vec3d(0.5, -0.25, 0);
|
||||
nodes[5] = cvf::Vec3d(1.25, 0.5, 0);
|
||||
nodes[6] = cvf::Vec3d(0.5, 1.25, 0);
|
||||
nodes[7] = cvf::Vec3d(-0.25, 0.5, 0);
|
||||
nodes[4] = cvf::Vec3d( 0.5, -0.25, 0 );
|
||||
nodes[5] = cvf::Vec3d( 1.25, 0.5, 0 );
|
||||
nodes[6] = cvf::Vec3d( 0.5, 1.25, 0 );
|
||||
nodes[7] = cvf::Vec3d( -0.25, 0.5, 0 );
|
||||
polygon.clear();
|
||||
|
||||
isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst(&nodes),
|
||||
cv1CubeFaceIndices,
|
||||
cv2CubeFaceIndices,
|
||||
1e-6);
|
||||
EXPECT_EQ((size_t)8, polygon.size());
|
||||
EXPECT_EQ((size_t)8, additionalVertices.size());
|
||||
EXPECT_TRUE(isOk);
|
||||
isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst( &nodes ),
|
||||
cv1CubeFaceIndices,
|
||||
cv2CubeFaceIndices,
|
||||
1e-6 );
|
||||
EXPECT_EQ( (size_t)8, polygon.size() );
|
||||
EXPECT_EQ( (size_t)8, additionalVertices.size() );
|
||||
EXPECT_TRUE( isOk );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(CellFaceIntersectionTst, FreeFacePolygon)
|
||||
TEST( CellFaceIntersectionTst, FreeFacePolygon )
|
||||
{
|
||||
std::vector<cvf::Vec3d> additionalVertices;
|
||||
cvf::Vec3dArray nodes;
|
||||
@@ -375,159 +375,159 @@ TEST(CellFaceIntersectionTst, FreeFacePolygon)
|
||||
size_t cv1CubeFaceIndices[4] = {0, 1, 2, 3};
|
||||
size_t cv2CubeFaceIndices[4] = {4, 5, 6, 7};
|
||||
|
||||
nodes.resize(8);
|
||||
nodes.setAll(cvf::Vec3d(0, 0, 0));
|
||||
nodes.resize( 8 );
|
||||
nodes.setAll( cvf::Vec3d( 0, 0, 0 ) );
|
||||
EdgeIntersectStorage<size_t> edgeIntersectionStorage;
|
||||
edgeIntersectionStorage.setVertexCount(nodes.size());
|
||||
edgeIntersectionStorage.setVertexCount( nodes.size() );
|
||||
|
||||
// Face 1
|
||||
nodes[0] = cvf::Vec3d(0, 0, 0);
|
||||
nodes[1] = cvf::Vec3d(1, 0, 0);
|
||||
nodes[2] = cvf::Vec3d(1, 1, 0);
|
||||
nodes[3] = cvf::Vec3d(0, 1, 0);
|
||||
nodes[0] = cvf::Vec3d( 0, 0, 0 );
|
||||
nodes[1] = cvf::Vec3d( 1, 0, 0 );
|
||||
nodes[2] = cvf::Vec3d( 1, 1, 0 );
|
||||
nodes[3] = cvf::Vec3d( 0, 1, 0 );
|
||||
// Face 2
|
||||
nodes[4] = cvf::Vec3d(0, 0, 0);
|
||||
nodes[5] = cvf::Vec3d(1, 0, 0);
|
||||
nodes[6] = cvf::Vec3d(1, 1, 0);
|
||||
nodes[7] = cvf::Vec3d(0, 1, 0);
|
||||
nodes[4] = cvf::Vec3d( 0, 0, 0 );
|
||||
nodes[5] = cvf::Vec3d( 1, 0, 0 );
|
||||
nodes[6] = cvf::Vec3d( 1, 1, 0 );
|
||||
nodes[7] = cvf::Vec3d( 0, 1, 0 );
|
||||
|
||||
bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst(&nodes),
|
||||
cv1CubeFaceIndices,
|
||||
cv2CubeFaceIndices,
|
||||
1e-6);
|
||||
EXPECT_EQ((size_t)4, polygon.size());
|
||||
EXPECT_EQ((size_t)0, additionalVertices.size());
|
||||
EXPECT_TRUE(isOk);
|
||||
bool isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst( &nodes ),
|
||||
cv1CubeFaceIndices,
|
||||
cv2CubeFaceIndices,
|
||||
1e-6 );
|
||||
EXPECT_EQ( (size_t)4, polygon.size() );
|
||||
EXPECT_EQ( (size_t)0, additionalVertices.size() );
|
||||
EXPECT_TRUE( isOk );
|
||||
|
||||
std::vector<bool> faceOverlapPolygonWinding;
|
||||
std::vector<std::vector<size_t>*> faceOverlapPolygons;
|
||||
faceOverlapPolygons.push_back(&polygon);
|
||||
faceOverlapPolygonWinding.push_back(true);
|
||||
faceOverlapPolygons.push_back( &polygon );
|
||||
faceOverlapPolygonWinding.push_back( true );
|
||||
|
||||
std::vector<size_t> partialFacePolygon;
|
||||
bool hasHoles = false;
|
||||
GeometryTools::calculatePartiallyFreeCubeFacePolygon(wrapArrayConst(&nodes),
|
||||
wrapArrayConst(cv1CubeFaceIndices, 4),
|
||||
Vec3d(0, 0, 1),
|
||||
faceOverlapPolygons,
|
||||
faceOverlapPolygonWinding,
|
||||
&partialFacePolygon,
|
||||
&hasHoles);
|
||||
GeometryTools::calculatePartiallyFreeCubeFacePolygon( wrapArrayConst( &nodes ),
|
||||
wrapArrayConst( cv1CubeFaceIndices, 4 ),
|
||||
Vec3d( 0, 0, 1 ),
|
||||
faceOverlapPolygons,
|
||||
faceOverlapPolygonWinding,
|
||||
&partialFacePolygon,
|
||||
&hasHoles );
|
||||
|
||||
// Face 1
|
||||
nodes[0] = cvf::Vec3d(0, 0, 0);
|
||||
nodes[1] = cvf::Vec3d(1, 0, 0);
|
||||
nodes[2] = cvf::Vec3d(1, 1, 0);
|
||||
nodes[3] = cvf::Vec3d(0, 1, 0);
|
||||
nodes[0] = cvf::Vec3d( 0, 0, 0 );
|
||||
nodes[1] = cvf::Vec3d( 1, 0, 0 );
|
||||
nodes[2] = cvf::Vec3d( 1, 1, 0 );
|
||||
nodes[3] = cvf::Vec3d( 0, 1, 0 );
|
||||
// Face 2
|
||||
nodes[4] = cvf::Vec3d(0.5, -0.25, 0);
|
||||
nodes[5] = cvf::Vec3d(1.25, 0.5, 0);
|
||||
nodes[6] = cvf::Vec3d(0.5, 1.25, 0);
|
||||
nodes[7] = cvf::Vec3d(-0.25, 0.5, 0);
|
||||
nodes[4] = cvf::Vec3d( 0.5, -0.25, 0 );
|
||||
nodes[5] = cvf::Vec3d( 1.25, 0.5, 0 );
|
||||
nodes[6] = cvf::Vec3d( 0.5, 1.25, 0 );
|
||||
nodes[7] = cvf::Vec3d( -0.25, 0.5, 0 );
|
||||
polygon.clear();
|
||||
|
||||
isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads(&polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst(&nodes),
|
||||
cv1CubeFaceIndices,
|
||||
cv2CubeFaceIndices,
|
||||
1e-6);
|
||||
EXPECT_EQ((size_t)8, polygon.size());
|
||||
EXPECT_EQ((size_t)8, additionalVertices.size());
|
||||
EXPECT_TRUE(isOk);
|
||||
isOk = GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon,
|
||||
&additionalVertices,
|
||||
&edgeIntersectionStorage,
|
||||
wrapArrayConst( &nodes ),
|
||||
cv1CubeFaceIndices,
|
||||
cv2CubeFaceIndices,
|
||||
1e-6 );
|
||||
EXPECT_EQ( (size_t)8, polygon.size() );
|
||||
EXPECT_EQ( (size_t)8, additionalVertices.size() );
|
||||
EXPECT_TRUE( isOk );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(CellFaceIntersectionTst, PolygonAreaNormal3D)
|
||||
TEST( CellFaceIntersectionTst, PolygonAreaNormal3D )
|
||||
{
|
||||
// Test special cases with zero area
|
||||
|
||||
{
|
||||
std::vector<cvf::Vec3d> vxs;
|
||||
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D(vxs);
|
||||
EXPECT_TRUE(area == cvf::Vec3d::ZERO);
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D( vxs );
|
||||
EXPECT_TRUE( area == cvf::Vec3d::ZERO );
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<cvf::Vec3d> vxs;
|
||||
vxs.push_back({0, 0, 0});
|
||||
vxs.push_back( {0, 0, 0} );
|
||||
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D(vxs);
|
||||
EXPECT_TRUE(area == cvf::Vec3d::ZERO);
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D( vxs );
|
||||
EXPECT_TRUE( area == cvf::Vec3d::ZERO );
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<cvf::Vec3d> vxs;
|
||||
vxs.push_back({0, 0, 0});
|
||||
vxs.push_back({0, 0, 1});
|
||||
vxs.push_back( {0, 0, 0} );
|
||||
vxs.push_back( {0, 0, 1} );
|
||||
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D(vxs);
|
||||
EXPECT_TRUE(area == cvf::Vec3d::ZERO);
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D( vxs );
|
||||
EXPECT_TRUE( area == cvf::Vec3d::ZERO );
|
||||
}
|
||||
|
||||
// Three points
|
||||
|
||||
{
|
||||
std::vector<cvf::Vec3d> vxs;
|
||||
vxs.push_back({0, 0, 0});
|
||||
vxs.push_back({0, 0, 1});
|
||||
vxs.push_back({0, 1, 1});
|
||||
vxs.push_back( {0, 0, 0} );
|
||||
vxs.push_back( {0, 0, 1} );
|
||||
vxs.push_back( {0, 1, 1} );
|
||||
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D(vxs);
|
||||
EXPECT_DOUBLE_EQ(-0.5, area.x());
|
||||
EXPECT_DOUBLE_EQ(0.0, area.y());
|
||||
EXPECT_DOUBLE_EQ(0.0, area.z());
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D( vxs );
|
||||
EXPECT_DOUBLE_EQ( -0.5, area.x() );
|
||||
EXPECT_DOUBLE_EQ( 0.0, area.y() );
|
||||
EXPECT_DOUBLE_EQ( 0.0, area.z() );
|
||||
}
|
||||
|
||||
// four identical points
|
||||
|
||||
{
|
||||
std::vector<cvf::Vec3d> vxs;
|
||||
vxs.push_back({0, 0, 0});
|
||||
vxs.push_back({0, 0, 0});
|
||||
vxs.push_back({0, 0, 0});
|
||||
vxs.push_back({0, 0, 0});
|
||||
vxs.push_back( {0, 0, 0} );
|
||||
vxs.push_back( {0, 0, 0} );
|
||||
vxs.push_back( {0, 0, 0} );
|
||||
vxs.push_back( {0, 0, 0} );
|
||||
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D(vxs);
|
||||
EXPECT_TRUE(area == cvf::Vec3d::ZERO);
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D( vxs );
|
||||
EXPECT_TRUE( area == cvf::Vec3d::ZERO );
|
||||
}
|
||||
|
||||
// Square of four points
|
||||
|
||||
{
|
||||
std::vector<cvf::Vec3d> vxs;
|
||||
vxs.push_back({0, 0, 0});
|
||||
vxs.push_back({0, 0, 1});
|
||||
vxs.push_back({0, 1, 1});
|
||||
vxs.push_back({0, 1, 0});
|
||||
vxs.push_back( {0, 0, 0} );
|
||||
vxs.push_back( {0, 0, 1} );
|
||||
vxs.push_back( {0, 1, 1} );
|
||||
vxs.push_back( {0, 1, 0} );
|
||||
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D(vxs);
|
||||
EXPECT_DOUBLE_EQ(-1.0, area.x());
|
||||
EXPECT_DOUBLE_EQ(0.0, area.y());
|
||||
EXPECT_DOUBLE_EQ(0.0, area.z());
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D( vxs );
|
||||
EXPECT_DOUBLE_EQ( -1.0, area.x() );
|
||||
EXPECT_DOUBLE_EQ( 0.0, area.y() );
|
||||
EXPECT_DOUBLE_EQ( 0.0, area.z() );
|
||||
}
|
||||
|
||||
// Square of four points + one point in center of square
|
||||
|
||||
{
|
||||
std::vector<cvf::Vec3d> vxs;
|
||||
vxs.push_back({0, 0, 0});
|
||||
vxs.push_back({0, 0, 1});
|
||||
vxs.push_back({0, 1, 1});
|
||||
vxs.push_back({0, 1, 0});
|
||||
vxs.push_back( {0, 0, 0} );
|
||||
vxs.push_back( {0, 0, 1} );
|
||||
vxs.push_back( {0, 1, 1} );
|
||||
vxs.push_back( {0, 1, 0} );
|
||||
|
||||
vxs.push_back({0, 0.5, 0.5}); // center of square
|
||||
vxs.push_back( {0, 0.5, 0.5} ); // center of square
|
||||
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D(vxs);
|
||||
EXPECT_DOUBLE_EQ(-0.75, area.x());
|
||||
EXPECT_DOUBLE_EQ(0.0, area.y());
|
||||
EXPECT_DOUBLE_EQ(0.0, area.z());
|
||||
cvf::Vec3d area = GeometryTools::polygonAreaNormal3D( vxs );
|
||||
EXPECT_DOUBLE_EQ( -0.75, area.x() );
|
||||
EXPECT_DOUBLE_EQ( 0.0, area.y() );
|
||||
EXPECT_DOUBLE_EQ( 0.0, area.z() );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user