MCPcopy Create free account
hub / github.com/ImageEngine/cortex / processInputs

Function processInputs

src/IECoreScene/MeshAlgoDistributePoints.cpp:234–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232};
233
234void processInputs(
235 const MeshPrimitive *mesh,
236 const std::string &refPosition, const std::string &uvSet, const std::string &densityMask,
237 const StringAlgo::MatchPattern &primitiveVariables,
238 const Canceller *canceller,
239 MeshPrimitivePtr &processedMesh,
240 PrimitiveVariable &uvVar, PrimitiveVariable &densityVar,
241 PrimitiveVariable &faceAreaVar, PrimitiveVariable &textureAreaVar
242)
243{
244 if( !mesh )
245 {
246 throw InvalidArgumentException( "MeshAlgo::distributePoints : The input mesh is not valid" );
247 }
248
249 IECoreScene::MeshPrimitivePtr meshWithUsedPrimVars = new MeshPrimitive();
250
251 // We need the topolgy of the source mesh to triangulate it
252 meshWithUsedPrimVars->setTopologyUnchecked( mesh->verticesPerFace(), mesh->vertexIds(), mesh->variableSize( PrimitiveVariable::Vertex ), mesh->interpolation() );
253
254 // Note that we do not transfer creases or corners - they do not affect distribution of points. If we were
255 // to add support for distributing onto the limit surface of a subdiv, then we might need to keep those ...
256 // but that would need to happen on an untriangulated mesh anyway.
257
258 // Transfer the subset of variables that we need
259 for( auto var : mesh->variables )
260 {
261 if(
262 var.first == uvSet || var.first == densityMask || var.first == refPosition || var.first == "P" ||
263 StringAlgo::matchMultiple( var.first, primitiveVariables )
264 )
265 {
266 meshWithUsedPrimVars->variables[ var.first ] = var.second;
267 }
268 }
269
270 processedMesh = MeshAlgo::triangulate( meshWithUsedPrimVars.get(), canceller );
271 if ( !processedMesh || !processedMesh->arePrimitiveVariablesValid() )
272 {
273 throw InvalidArgumentException( "MeshAlgo::distributePoints : The input mesh could not be triangulated" );
274 }
275
276 auto uvIt = processedMesh->variables.find( uvSet );
277 if( uvIt != processedMesh->variables.end() )
278 {
279 PrimitiveVariable::Interpolation interp = uvIt->second.interpolation;
280 if(
281 uvIt->second.data->typeId() == V2fVectorDataTypeId &&
282 (
283 interp == PrimitiveVariable::Vertex ||
284 interp == PrimitiveVariable::Varying ||
285 interp == PrimitiveVariable::FaceVarying
286 )
287 )
288 {
289 uvVar = uvIt->second;
290 }
291 }

Callers 1

distributePointsMethod · 0.85

Calls 15

InvalidArgumentExceptionFunction · 0.85
triangulateFunction · 0.85
PrimitiveVariableFunction · 0.85
setTopologyUncheckedMethod · 0.80
verticesPerFaceMethod · 0.80
vertexIdsMethod · 0.80
interpolationMethod · 0.80
typeIdMethod · 0.80
strFunction · 0.50
variableSizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected