mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use only one implementation of lineIndicesFromQuadVertexArray (#7980)
* Use only one implementation of lineIndicesFromQuadVertexArray
This commit is contained in:
parent
a5b80c649b
commit
0c69cdf203
@ -27,6 +27,7 @@
|
|||||||
#include "cvfOutlineEdgeExtractor.h"
|
#include "cvfOutlineEdgeExtractor.h"
|
||||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||||
#include "cvfScalarMapper.h"
|
#include "cvfScalarMapper.h"
|
||||||
|
#include "cvfStructGridGeometryGenerator.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -84,7 +85,8 @@ ref<DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawable()
|
|||||||
ref<DrawableGeo> geo = new DrawableGeo;
|
ref<DrawableGeo> geo = new DrawableGeo;
|
||||||
geo->setVertexArray( m_quadVertices.p() );
|
geo->setVertexArray( m_quadVertices.p() );
|
||||||
|
|
||||||
ref<UIntArray> indices = lineIndicesFromQuadVertexArray( m_quadVertices.p() );
|
ref<UIntArray> indices = cvf::StructGridGeometryGenerator::lineIndicesFromQuadVertexArray( m_quadVertices.p() );
|
||||||
|
|
||||||
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt( PT_LINES );
|
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt( PT_LINES );
|
||||||
prim->setIndices( indices.p() );
|
prim->setIndices( indices.p() );
|
||||||
|
|
||||||
@ -101,7 +103,7 @@ ref<DrawableGeo> RivFemPartGeometryGenerator::createOutlineMeshDrawable( double
|
|||||||
|
|
||||||
cvf::OutlineEdgeExtractor ee( creaseAngle, *m_quadVertices );
|
cvf::OutlineEdgeExtractor ee( creaseAngle, *m_quadVertices );
|
||||||
|
|
||||||
ref<UIntArray> indices = lineIndicesFromQuadVertexArray( m_quadVertices.p() );
|
ref<UIntArray> indices = cvf::StructGridGeometryGenerator::lineIndicesFromQuadVertexArray( m_quadVertices.p() );
|
||||||
ee.addPrimitives( 4, *indices );
|
ee.addPrimitives( 4, *indices );
|
||||||
|
|
||||||
ref<cvf::UIntArray> lineIndices = ee.lineIndices();
|
ref<cvf::UIntArray> lineIndices = ee.lineIndices();
|
||||||
@ -120,40 +122,6 @@ ref<DrawableGeo> RivFemPartGeometryGenerator::createOutlineMeshDrawable( double
|
|||||||
return geo;
|
return geo;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
///
|
|
||||||
///
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
ref<UIntArray> RivFemPartGeometryGenerator::lineIndicesFromQuadVertexArray( const Vec3fArray* vertexArray )
|
|
||||||
{
|
|
||||||
CVF_ASSERT( vertexArray );
|
|
||||||
|
|
||||||
size_t numVertices = vertexArray->size();
|
|
||||||
int numQuads = static_cast<int>( numVertices / 4 );
|
|
||||||
CVF_ASSERT( numVertices % 4 == 0 );
|
|
||||||
|
|
||||||
ref<UIntArray> indices = new UIntArray;
|
|
||||||
indices->resize( numQuads * 8 );
|
|
||||||
|
|
||||||
#pragma omp parallel for
|
|
||||||
for ( int i = 0; i < numQuads; i++ )
|
|
||||||
{
|
|
||||||
int idx = 8 * i;
|
|
||||||
indices->set( idx + 0, i * 4 + 0 );
|
|
||||||
indices->set( idx + 1, i * 4 + 1 );
|
|
||||||
indices->set( idx + 2, i * 4 + 1 );
|
|
||||||
indices->set( idx + 3, i * 4 + 2 );
|
|
||||||
indices->set( idx + 4, i * 4 + 2 );
|
|
||||||
indices->set( idx + 5, i * 4 + 3 );
|
|
||||||
indices->set( idx + 6, i * 4 + 3 );
|
|
||||||
indices->set( idx + 7, i * 4 + 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return indices;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -336,7 +304,8 @@ cvf::ref<cvf::DrawableGeo>
|
|||||||
ref<DrawableGeo> geo = new DrawableGeo;
|
ref<DrawableGeo> geo = new DrawableGeo;
|
||||||
geo->setVertexArray( quadVertices.p() );
|
geo->setVertexArray( quadVertices.p() );
|
||||||
|
|
||||||
ref<UIntArray> indices = lineIndicesFromQuadVertexArray( quadVertices.p() );
|
ref<UIntArray> indices = cvf::StructGridGeometryGenerator::lineIndicesFromQuadVertexArray( quadVertices.p() );
|
||||||
|
|
||||||
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt( PT_LINES );
|
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt( PT_LINES );
|
||||||
prim->setIndices( indices.p() );
|
prim->setIndices( indices.p() );
|
||||||
|
|
||||||
|
@ -96,7 +96,6 @@ public:
|
|||||||
const cvf::Vec3d& displayModelOffset );
|
const cvf::Vec3d& displayModelOffset );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static cvf::ref<cvf::UIntArray> lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray );
|
|
||||||
void computeArrays();
|
void computeArrays();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -56,7 +56,7 @@ cvf::ref<cvf::Part> RivBoxGeometryGenerator::createBoxFromVertices( const std::v
|
|||||||
|
|
||||||
geo->setVertexArray( cvfVertices.p() );
|
geo->setVertexArray( cvfVertices.p() );
|
||||||
|
|
||||||
cvf::ref<cvf::UIntArray> indices = lineIndicesFromQuadVertexArray( cvfVertices.p() );
|
cvf::ref<cvf::UIntArray> indices = cvf::StructGridGeometryGenerator::lineIndicesFromQuadVertexArray( cvfVertices.p() );
|
||||||
|
|
||||||
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt( cvf::PT_LINES );
|
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt( cvf::PT_LINES );
|
||||||
prim->setIndices( indices.p() );
|
prim->setIndices( indices.p() );
|
||||||
@ -75,33 +75,3 @@ cvf::ref<cvf::Part> RivBoxGeometryGenerator::createBoxFromVertices( const std::v
|
|||||||
|
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
cvf::ref<cvf::UIntArray> RivBoxGeometryGenerator::lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray )
|
|
||||||
{
|
|
||||||
// TODO - see issue #7890
|
|
||||||
|
|
||||||
CVF_ASSERT( vertexArray );
|
|
||||||
|
|
||||||
size_t numVertices = vertexArray->size();
|
|
||||||
int numQuads = static_cast<int>( numVertices / 4 );
|
|
||||||
CVF_ASSERT( numVertices % 4 == 0 );
|
|
||||||
|
|
||||||
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray;
|
|
||||||
indices->resize( numQuads * 8 );
|
|
||||||
|
|
||||||
#pragma omp parallel for
|
|
||||||
for ( int i = 0; i < numQuads; i++ )
|
|
||||||
{
|
|
||||||
int idx = 8 * i;
|
|
||||||
indices->set( idx + 0, i * 4 + 0 );
|
|
||||||
indices->set( idx + 1, i * 4 + 1 );
|
|
||||||
indices->set( idx + 2, i * 4 + 1 );
|
|
||||||
indices->set( idx + 3, i * 4 + 2 );
|
|
||||||
indices->set( idx + 4, i * 4 + 2 );
|
|
||||||
indices->set( idx + 5, i * 4 + 3 );
|
|
||||||
indices->set( idx + 6, i * 4 + 3 );
|
|
||||||
indices->set( idx + 7, i * 4 + 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return indices;
|
|
||||||
}
|
|
||||||
|
@ -36,8 +36,6 @@ class RivBoxGeometryGenerator
|
|||||||
public:
|
public:
|
||||||
static cvf::ref<cvf::Part> createBoxFromVertices( const std::vector<cvf::Vec3f>& vertices, const cvf::Color3f color );
|
static cvf::ref<cvf::Part> createBoxFromVertices( const std::vector<cvf::Vec3f>& vertices, const cvf::Color3f color );
|
||||||
|
|
||||||
static cvf::ref<cvf::UIntArray> lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RivBoxGeometryGenerator(){};
|
RivBoxGeometryGenerator(){};
|
||||||
};
|
};
|
||||||
|
@ -79,7 +79,8 @@ cvf::ref<cvf::DrawableGeo> RivFaultGeometryGenerator::createMeshDrawable()
|
|||||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||||
geo->setVertexArray( m_vertices.p() );
|
geo->setVertexArray( m_vertices.p() );
|
||||||
|
|
||||||
cvf::ref<cvf::UIntArray> indices = lineIndicesFromQuadVertexArray( m_vertices.p() );
|
cvf::ref<cvf::UIntArray> indices = cvf::StructGridGeometryGenerator::lineIndicesFromQuadVertexArray( m_vertices.p() );
|
||||||
|
|
||||||
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt( cvf::PT_LINES );
|
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt( cvf::PT_LINES );
|
||||||
prim->setIndices( indices.p() );
|
prim->setIndices( indices.p() );
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ cvf::ref<cvf::DrawableGeo> RivFaultGeometryGenerator::createOutlineMeshDrawable(
|
|||||||
|
|
||||||
cvf::OutlineEdgeExtractor ee( creaseAngle, *m_vertices );
|
cvf::OutlineEdgeExtractor ee( creaseAngle, *m_vertices );
|
||||||
|
|
||||||
cvf::ref<cvf::UIntArray> indices = lineIndicesFromQuadVertexArray( m_vertices.p() );
|
cvf::ref<cvf::UIntArray> indices = cvf::StructGridGeometryGenerator::lineIndicesFromQuadVertexArray( m_vertices.p() );
|
||||||
ee.addPrimitives( 4, *indices );
|
ee.addPrimitives( 4, *indices );
|
||||||
|
|
||||||
cvf::ref<cvf::UIntArray> lineIndices = ee.lineIndices();
|
cvf::ref<cvf::UIntArray> lineIndices = ee.lineIndices();
|
||||||
@ -115,37 +116,6 @@ cvf::ref<cvf::DrawableGeo> RivFaultGeometryGenerator::createOutlineMeshDrawable(
|
|||||||
return geo;
|
return geo;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
cvf::ref<cvf::UIntArray> RivFaultGeometryGenerator::lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray )
|
|
||||||
{
|
|
||||||
CVF_ASSERT( vertexArray );
|
|
||||||
|
|
||||||
size_t numVertices = vertexArray->size();
|
|
||||||
int numQuads = static_cast<int>( numVertices / 4 );
|
|
||||||
CVF_ASSERT( numVertices % 4 == 0 );
|
|
||||||
|
|
||||||
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray;
|
|
||||||
indices->resize( numQuads * 8 );
|
|
||||||
|
|
||||||
#pragma omp parallel for
|
|
||||||
for ( int i = 0; i < numQuads; i++ )
|
|
||||||
{
|
|
||||||
int idx = 8 * i;
|
|
||||||
indices->set( idx + 0, i * 4 + 0 );
|
|
||||||
indices->set( idx + 1, i * 4 + 1 );
|
|
||||||
indices->set( idx + 2, i * 4 + 1 );
|
|
||||||
indices->set( idx + 3, i * 4 + 2 );
|
|
||||||
indices->set( idx + 4, i * 4 + 2 );
|
|
||||||
indices->set( idx + 5, i * 4 + 3 );
|
|
||||||
indices->set( idx + 6, i * 4 + 3 );
|
|
||||||
indices->set( idx + 7, i * 4 + 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return indices;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -57,8 +57,6 @@ public:
|
|||||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||||
cvf::ref<cvf::DrawableGeo> createOutlineMeshDrawable( double creaseAngle );
|
cvf::ref<cvf::DrawableGeo> createOutlineMeshDrawable( double creaseAngle );
|
||||||
|
|
||||||
static cvf::ref<cvf::UIntArray> lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void computeArrays();
|
void computeArrays();
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||||
#include "cvfRenderStateDepth.h"
|
#include "cvfRenderStateDepth.h"
|
||||||
#include "cvfScalarMapperContinuousLinear.h"
|
#include "cvfScalarMapperContinuousLinear.h"
|
||||||
|
#include "cvfStructGridGeometryGenerator.h"
|
||||||
#include "cvfTransform.h"
|
#include "cvfTransform.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@ -1077,7 +1078,8 @@ cvf::ref<cvf::DrawableGeo>
|
|||||||
|
|
||||||
cvf::ref<cvf::DrawableGeo> stimPlanMeshGeo = new cvf::DrawableGeo;
|
cvf::ref<cvf::DrawableGeo> stimPlanMeshGeo = new cvf::DrawableGeo;
|
||||||
stimPlanMeshGeo->setVertexArray( stimPlanMeshVertexList );
|
stimPlanMeshGeo->setVertexArray( stimPlanMeshVertexList );
|
||||||
cvf::ref<cvf::UIntArray> indices = RivFaultGeometryGenerator::lineIndicesFromQuadVertexArray( stimPlanMeshVertexList );
|
cvf::ref<cvf::UIntArray> indices =
|
||||||
|
cvf::StructGridGeometryGenerator::lineIndicesFromQuadVertexArray( stimPlanMeshVertexList );
|
||||||
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt( cvf::PT_LINES );
|
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt( cvf::PT_LINES );
|
||||||
prim->setIndices( indices.p() );
|
prim->setIndices( indices.p() );
|
||||||
|
|
||||||
|
@ -324,12 +324,12 @@ ref<UIntArray> StructGridGeometryGenerator::lineIndicesFromQuadVertexArray( cons
|
|||||||
CVF_ASSERT( numVertices % 4 == 0 );
|
CVF_ASSERT( numVertices % 4 == 0 );
|
||||||
|
|
||||||
ref<UIntArray> indices = new UIntArray;
|
ref<UIntArray> indices = new UIntArray;
|
||||||
indices->resize( numQuads * 8 );
|
indices->resize( (size_t)numQuads * 8 );
|
||||||
|
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
for ( int i = 0; i < numQuads; i++ )
|
for ( int i = 0; i < numQuads; i++ )
|
||||||
{
|
{
|
||||||
int idx = 8 * i;
|
size_t idx = (size_t)i * 8;
|
||||||
indices->set( idx + 0, i * 4 + 0 );
|
indices->set( idx + 0, i * 4 + 0 );
|
||||||
indices->set( idx + 1, i * 4 + 1 );
|
indices->set( idx + 1, i * 4 + 1 );
|
||||||
indices->set( idx + 2, i * 4 + 1 );
|
indices->set( idx + 2, i * 4 + 1 );
|
||||||
|
@ -200,9 +200,9 @@ public:
|
|||||||
static ref<DrawableGeo> createMeshDrawableFromSingleCell( const StructGridInterface* grid,
|
static ref<DrawableGeo> createMeshDrawableFromSingleCell( const StructGridInterface* grid,
|
||||||
size_t cellIndex,
|
size_t cellIndex,
|
||||||
const cvf::Vec3d& displayModelOffset );
|
const cvf::Vec3d& displayModelOffset );
|
||||||
|
static ref<UIntArray> lineIndicesFromQuadVertexArray( const Vec3fArray* vertexArray );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static ref<UIntArray> lineIndicesFromQuadVertexArray( const Vec3fArray* vertexArray );
|
|
||||||
bool isCellFaceVisible( size_t i, size_t j, size_t k, StructGridInterface::FaceType face ) const;
|
bool isCellFaceVisible( size_t i, size_t j, size_t k, StructGridInterface::FaceType face ) const;
|
||||||
|
|
||||||
void computeArrays();
|
void computeArrays();
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "cvfDrawableGeo.h"
|
#include "cvfDrawableGeo.h"
|
||||||
#include "cvfGeometryBuilderFaceList.h"
|
#include "cvfGeometryBuilderFaceList.h"
|
||||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||||
|
#include "cvfStructGridGeometryGenerator.h"
|
||||||
|
|
||||||
using namespace cvf;
|
using namespace cvf;
|
||||||
|
|
||||||
@ -59,7 +60,8 @@ cvf::ref<cvf::DrawableGeo> BoxManipulatorGeometryGenerator::createBoundingBoxMes
|
|||||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||||
geo->setVertexArray( m_vertices.p() );
|
geo->setVertexArray( m_vertices.p() );
|
||||||
|
|
||||||
cvf::ref<cvf::UIntArray> indices = lineIndicesFromQuadVertexArray( m_vertices.p() );
|
cvf::ref<cvf::UIntArray> indices = cvf::StructGridGeometryGenerator::lineIndicesFromQuadVertexArray( m_vertices.p() );
|
||||||
|
|
||||||
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt( cvf::PT_LINES );
|
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt( cvf::PT_LINES );
|
||||||
prim->setIndices( indices.p() );
|
prim->setIndices( indices.p() );
|
||||||
|
|
||||||
@ -88,35 +90,4 @@ void BoxManipulatorGeometryGenerator::calculateArrays()
|
|||||||
// TODO: Rotate generated vertices
|
// TODO: Rotate generated vertices
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
cvf::ref<cvf::UIntArray> BoxManipulatorGeometryGenerator::lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray )
|
|
||||||
{
|
|
||||||
CVF_ASSERT( vertexArray );
|
|
||||||
|
|
||||||
size_t numVertices = vertexArray->size();
|
|
||||||
int numQuads = static_cast<int>( numVertices / 4 );
|
|
||||||
CVF_ASSERT( numVertices % 4 == 0 );
|
|
||||||
|
|
||||||
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray;
|
|
||||||
indices->resize( numQuads * 8 );
|
|
||||||
|
|
||||||
#pragma omp parallel for
|
|
||||||
for ( int i = 0; i < numQuads; i++ )
|
|
||||||
{
|
|
||||||
int idx = 8 * i;
|
|
||||||
indices->set( idx + 0, i * 4 + 0 );
|
|
||||||
indices->set( idx + 1, i * 4 + 1 );
|
|
||||||
indices->set( idx + 2, i * 4 + 1 );
|
|
||||||
indices->set( idx + 3, i * 4 + 2 );
|
|
||||||
indices->set( idx + 4, i * 4 + 2 );
|
|
||||||
indices->set( idx + 5, i * 4 + 3 );
|
|
||||||
indices->set( idx + 6, i * 4 + 3 );
|
|
||||||
indices->set( idx + 7, i * 4 + 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return indices;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace caf
|
} // namespace caf
|
||||||
|
@ -32,8 +32,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
void calculateArrays();
|
void calculateArrays();
|
||||||
|
|
||||||
static cvf::ref<cvf::UIntArray> lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cvf::Vec3d m_origin;
|
cvf::Vec3d m_origin;
|
||||||
cvf::Vec3d m_size;
|
cvf::Vec3d m_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user