void unmap_tags( Mesh* old_mesh, Mesh* new_mesh, Int ent_dim, LOs new_ents2old_ents) { for (Int i = 0; i < old_mesh->ntags(ent_dim); ++i) { auto tag = old_mesh->get_tag(ent_dim, i); if (is<I8>(tag)) { new_mesh->add_tag<I8>(ent_dim, tag->name(), tag->ncomps(), tag->xfer(), tag->outflags(), unmap(new_ents2old_ents, to<I8>(tag)->array(), tag->ncomps())); } else if (is<I32>(tag)) { new_mesh->add_tag<I32>(ent_dim, tag->name(), tag->ncomps(), tag->xfer(), tag->outflags(), unmap(new_ents2old_ents, to<I32>(tag)->array(), tag->ncomps())); } else if (is<I64>(tag)) { new_mesh->add_tag<I64>(ent_dim, tag->name(), tag->ncomps(), tag->xfer(), tag->outflags(), unmap(new_ents2old_ents, to<I64>(tag)->array(), tag->ncomps())); } else if (is<Real>(tag)) { new_mesh->add_tag<Real>(ent_dim, tag->name(), tag->ncomps(), tag->xfer(), tag->outflags(), unmap(new_ents2old_ents, to<Real>(tag)->array(), tag->ncomps())); } } }
//--------------------------------------------------------------------- void CqImagersource::Initialise( const CqRegion& DRegion, IqChannelBuffer* buffer ) { AQSIS_TIME_SCOPE(Imager_shading); // We use one less than the bucket width and height here, since these // resolutions really represent one less than the number of shaded points // in each direction. (Usually they describe the number of micropolygons // on a grid which is one less than the number of shaded vertices. This // concept has no real analogue in context of an imager shader.) TqInt uGridRes = DRegion.width()-1; TqInt vGridRes = DRegion.height()-1; TqInt x = DRegion.xMin(); TqInt y = DRegion.yMin(); m_uYOrigin = static_cast<TqInt>( y ); m_uXOrigin = static_cast<TqInt>( x ); m_uGridRes = uGridRes; m_vGridRes = vGridRes; TqInt mode = QGetRenderContext() ->poptCurrent()->GetIntegerOption( "System", "DisplayMode" ) [ 0 ]; TqFloat components; TqInt j, i; TqFloat shuttertime = QGetRenderContext() ->poptCurrent()->GetFloatOption( "System", "Shutter" ) [ 0 ]; components = mode & DMode_RGB ? 3 : 0; components += mode & DMode_A ? 1 : 0; components = mode & DMode_Z ? 1 : components; TqInt Uses = ( 1 << EnvVars_P ) | ( 1 << EnvVars_Ci ) | ( 1 << EnvVars_Oi | ( 1 << EnvVars_ncomps ) | ( 1 << EnvVars_time ) | ( 1 << EnvVars_alpha ) | ( 1 << EnvVars_s ) | ( 1 << EnvVars_t ) ); m_pShaderExecEnv->Initialise( uGridRes, vGridRes, uGridRes * vGridRes, (uGridRes+1)*(vGridRes+1), true, IqAttributesPtr(), IqTransformPtr(), m_pShader.get(), Uses ); // Initialise the geometric parameters in the shader exec env. TqInt numShadingPoints = (uGridRes+1) * (vGridRes+1); P() ->Initialise( numShadingPoints ); Ci() ->Initialise( numShadingPoints ); Oi() ->Initialise( numShadingPoints ); alpha() ->Initialise( numShadingPoints ); s() ->Initialise( numShadingPoints ); t() ->Initialise( numShadingPoints ); //TODO dtime is not initialised yet //dtime().Initialise(uGridRes, vGridRes, i); ncomps() ->SetFloat( components ); time() ->SetFloat( shuttertime ); m_pShader->Initialise( uGridRes, vGridRes, (uGridRes+1)*(vGridRes+1), m_pShaderExecEnv.get() ); TqUint CiIndex = buffer->getChannelIndex("Ci"); TqUint OiIndex = buffer->getChannelIndex("Oi"); TqUint coverageIndex = buffer->getChannelIndex("coverage"); for ( j = 0; j < vGridRes+1; j++ ) { for ( i = 0; i < uGridRes+1; i++ ) { TqInt off = j * ( uGridRes + 1 ) + i; P() ->SetPoint( CqVector3D( x + i, y + j, 0.0 ), off ); Ci() ->SetColor( CqColor((*buffer)(i, j, CiIndex)[0], (*buffer)(i, j, CiIndex)[1], (*buffer)(i, j, CiIndex)[2]), off ); CqColor opa((*buffer)(i, j, OiIndex)[0], (*buffer)(i, j, OiIndex)[1], (*buffer)(i, j, OiIndex)[2]); Oi() ->SetColor( opa, off ); TqFloat avopa = ( opa.r() + opa.g() + opa.b() ) /3.0f; alpha() ->SetFloat( (*buffer)(i, j, coverageIndex)[0] * avopa, off ); s() ->SetFloat( x + i + 0.5, off ); t() ->SetFloat( y + j + 0.5, off ); } } // Execute the Shader VM if ( m_pShader ) { m_pShader->Evaluate( m_pShaderExecEnv.get() ); alpha() ->SetFloat( 1.0f ); /* by default 3delight/bmrt set it to 1.0 */ } }
Omega_h_Comparison compare_meshes( Mesh* a, Mesh* b, Real tol, Real floor, bool verbose, bool full) { CHECK(a->comm()->size() == b->comm()->size()); CHECK(a->comm()->rank() == b->comm()->rank()); auto comm = a->comm(); auto should_print = verbose && (comm->rank() == 0); if (a->dim() != b->dim()) { if (should_print) std::cout << "mesh dimensions differ\n"; return OMEGA_H_DIFF; } Omega_h_Comparison result = OMEGA_H_SAME; for (Int dim = 0; dim <= a->dim(); ++dim) { if (a->nglobal_ents(dim) != b->nglobal_ents(dim)) { if (should_print) { std::cout << "global " << singular_names[dim] << " counts differ\n"; } return OMEGA_H_DIFF; } if (!full && (0 < dim) && (dim < a->dim())) continue; auto a_globals = a->ask_globals(dim); auto b_globals = b->ask_globals(dim); auto a_dist = copies_to_linear_owners(comm, a_globals); auto b_dist = copies_to_linear_owners(comm, b_globals); if (dim > 0) { auto a_conn = get_local_conn(a, dim, full); auto b_conn = get_local_conn(b, dim, full); auto ok = compare_copy_data( dim, a_conn, a_dist, b_conn, b_dist, dim + 1, 0.0, 0.0); if (!ok) { if (should_print) { std::cout << singular_names[dim] << " connectivity doesn't match\n"; } result = OMEGA_H_DIFF; continue; } } for (Int i = 0; i < a->ntags(dim); ++i) { auto tag = a->get_tag(dim, i); auto const& name = tag->name(); if (!b->has_tag(dim, name)) { if (should_print) { std::cout << singular_names[dim] << " tag \"" << name << "\" exists in first mesh but not second\n"; } result = OMEGA_H_DIFF; continue; } auto ncomps = tag->ncomps(); bool ok = false; switch (tag->type()) { case OMEGA_H_I8: ok = compare_copy_data(dim, a->get_array<I8>(dim, name), a_dist, b->get_array<I8>(dim, name), b_dist, ncomps, tol, floor); break; case OMEGA_H_I32: ok = compare_copy_data(dim, a->get_array<I32>(dim, name), a_dist, b->get_array<I32>(dim, name), b_dist, ncomps, tol, floor); break; case OMEGA_H_I64: ok = compare_copy_data(dim, a->get_array<I64>(dim, name), a_dist, b->get_array<I64>(dim, name), b_dist, ncomps, tol, floor); break; case OMEGA_H_F64: ok = compare_copy_data(dim, a->get_array<Real>(dim, name), a_dist, b->get_array<Real>(dim, name), b_dist, ncomps, tol, floor); break; } if (!ok) { if (should_print) { std::cout << singular_names[dim] << " tag \"" << name << "\" values are different\n"; } comm->barrier(); result = OMEGA_H_DIFF; } } for (Int i = 0; i < b->ntags(dim); ++i) { auto tag = b->get_tag(dim, i); if (!a->has_tag(dim, tag->name())) { if (should_print) { std::cout << singular_names[dim] << " tag \"" << tag->name() << "\" exists in second mesh but not in first\n"; } if (result == OMEGA_H_SAME) { result = OMEGA_H_MORE; } } } } return result; }