Skip to content

Commit

Permalink
Hacking
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldresser-ie committed Nov 14, 2024
1 parent 92bee1a commit 3ea5e6a
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions src/IECoreScene/MeshAlgoSplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ void initializeFaceToSegments(

IECoreScene::MeshAlgo::MeshSplitter::MeshSplitter( ConstMeshPrimitivePtr mesh, const PrimitiveVariable &segmentPrimitiveVariable, const IECore::Canceller *canceller ) : m_mesh( mesh ), m_segmentPrimitiveVariable( segmentPrimitiveVariable )
{
throw IECore::Exception( "Hello world" );
if( segmentPrimitiveVariable.interpolation != IECoreScene::PrimitiveVariable::Interpolation::Uniform )
{
throw IECore::Exception( "Primitive variable passed to MeshSplitter must be uniform." );
Expand Down Expand Up @@ -596,6 +597,13 @@ class Reindexer
}
}
}

std::string message;
for( int i = 0; i < (int)dataRemap.size(); i++ )
{
message += std::to_string( dataRemap[ i ] ) + " ";
}
throw IECore::Exception( "DEBUG: " + message );
}

private:
Expand All @@ -611,6 +619,11 @@ class Reindexer

m_indicesComputed = true;

std::cout << "COMPUTE INDICES\n";


m_numIdsUsed = 0;

for( unsigned int blockId = 0; blockId < m_fromOldIds.size(); blockId++ )
{
auto &block = m_fromOldIds[ blockId ];
Expand All @@ -629,13 +642,55 @@ class Reindexer
}
}


for( int &id : m_newIndices )
{
int blockId = id / m_blockSize;
int subIndex = id % m_blockSize;

std::cout << id << " : " << (*m_fromOldIds[ blockId ])[subIndex] << "\n";
id = (*m_fromOldIds[ blockId ])[subIndex];

}

std::cout << "DONE COMPUTE INDICES\n";


std::vector<int> debugIds;

for( unsigned int blockId = 0; blockId < m_fromOldIds.size(); blockId++ )
{
auto &block = m_fromOldIds[ blockId ];
if( !block )
{
continue;
}

for( int i = 0; i < m_blockSize; i++ )
{
if( (*block)[i] != -1 )
{
debugIds.push_back( (*block)[i] );
}
}
}

bool failed = false;
for( int i = 0; i < (int)debugIds.size(); i++ )
{
failed |= debugIds[i] != i;
}

if( failed )
{
std::string message;
for( int i = 0; i < (int)debugIds.size(); i++ )
{
message += std::to_string( debugIds[ i ] ) + " ";
}
throw IECore::Exception( "BAD IDS " + message );
}

}

// IntVectorData to hold the new indices
Expand Down Expand Up @@ -868,6 +923,24 @@ MeshPrimitivePtr IECoreScene::MeshAlgo::MeshSplitter::mesh( int segmentId, const
std::vector<int> vertRemapBackwards;
vertReindexer.getDataRemapping( vertRemapBackwards );

bool failure = false;
for( int i = startIndex; i < endIndex; i++ )
{
int originalFaceIndex = m_faceRemap[i];
int faceVerts = sourceVerticesPerFace[ originalFaceIndex ];
int faceStart = m_faceIndices[ originalFaceIndex ];
for( int j = 0; j < faceVerts; j++ )
{
int q = sourceVertexIds[ faceStart + j ];
failure |= vertRemapBackwards[ vertReindexer.testIndex( q ) ] != q;
}
}

if( failure )
{
throw IECore::Exception( "detected" );
}

MeshPrimitivePtr ret = new MeshPrimitive( verticesPerFaceData, vertReindexer.getNewIndices(), m_mesh->interpolation() );

// In order to remap the corners, we test every vertex in the original corner list, and see if it is
Expand Down

0 comments on commit 3ea5e6a

Please sign in to comment.