void MainWindow::on_remplirDossier_clicked() { saisirinscription uvw(fac); if (uvw.exec()){ fillMainWindow(); } }
void MainWindow::on_inscrireSemestre_clicked() { ajoutSemestres uvw(fac); if (uvw.exec()){ fillMainWindow(); } }
void MainWindow::modifiercursus() { modifiercursuswindow uvw(fac); if (uvw.exec()){ fillMainWindow(); } }
void MainWindow::supprcursus() { supprimerCursus uvw(fac); if (uvw.exec()){ fillMainWindow(); } }
void MainWindow::ajoutercursus() { ajoutcursuswindow uvw(fac); if (uvw.exec()){ fillMainWindow(); } }
void MainWindow::suppruv() { supprimerUVwindow uvw(fac); if (uvw.exec()){ fillMainWindow(); } }
void MainWindow::on_ajouteruv() { ajouterUVwindow uvw(fac); if (uvw.exec()){ fillMainWindow(); } }
bool IndexedTriangleMesh::closestIntersectionModel(const Ray &ray, double maxLambda, RayIntersection& intersection) const { double closestLambda = maxLambda; Vec3d closestbary; int closestTri = -1; Vec3d bary; double lambda; // Loop over all stored triangles to find a possible intersection between ray // and any triangle for (size_t i=0;i<mIndices.size();i+=3) { const int i0 = mIndices[i+0]; const int i1 = mIndices[i+1]; const int i2 = mIndices[i+2]; if (Intersection::lineTriangle(ray,mVertexPosition[i0],mVertexPosition[i1],mVertexPosition[i2],bary,lambda) && lambda > 0 && lambda < closestLambda) { closestLambda = lambda; closestbary = bary; closestTri = (int)i; } } // If an intersection occurred, compute the normal and the uv coordinates based // on the barycentric coordinates of the hit point if (closestTri >= 0) { const int i0 = mIndices[closestTri+0]; const int i1 = mIndices[closestTri+1]; const int i2 = mIndices[closestTri+2]; Vec3d n; if(mVertexNormal.empty()) n = cross(mVertexPosition[i1]-mVertexPosition[i0],mVertexPosition[i2]-mVertexPosition[i0]).normalize(); else n = (mVertexNormal[i0]*closestbary[0]+ mVertexNormal[i1]*closestbary[1]+ mVertexNormal[i2]*closestbary[2]).normalize(); Vec3d uvw(0,0,0); if(!mVertexTextureCoordinate.empty()) uvw = (mVertexTextureCoordinate[i0]*closestbary[0]+ mVertexTextureCoordinate[i1]*closestbary[1]+ mVertexTextureCoordinate[i2]*closestbary[2]); intersection=RayIntersection(ray,shared_from_this(),closestLambda,n,uvw); return true; } return false; }
double M(int m, int n, int l) { double u; double v; double w; uvw(u, v, w, m, n, l); return u * U(m, n, l) + v * V(m, n, l) + w * W(m, n, l); }
/** * Compute barycentric coordinates for a given triangle and a given point */ point_t barycentric(primitive::triangle_t const& tri, point_t const& point) { vector_t v0 = tri.v1 - tri.v0, v1 = tri.v2 - tri.v0, v2 = point - tri.v0; float d00 = glm::dot(v0, v0); float d01 = glm::dot(v0, v1); float d11 = glm::dot(v1, v1); float d20 = glm::dot(v2, v0); float d21 = glm::dot(v2, v1); float d = d00 * d11 - d01 * d01; point_t uvw(0, 0, 0); uvw.y = (d11 * d20 - d01 * d21) / d; uvw.z = (d00 * d21 - d01 * d20) / d; uvw.x = 1.0f - uvw.y - uvw.z; return uvw; }
void TweakMouseProc::AverageUVW() { if (mHitLD) { Point3 uvw(0.0f,0.0f,0.0f); int ct = 0; for (int i = 0; i < mHitLD->GetNumberTVEdges(); i++ ) { if (!mHitLD->GetTVEdgeHidden(i)) { if (mHitLD->GetTVEdgeVert(i,0) == mHitTVVert) { uvw += mHitLD->GetTVVert(mHitLD->GetTVEdgeVert(i,1)); ct++; } else if (mHitLD->GetTVEdgeVert(i,1) == mHitTVVert) { uvw += mHitLD->GetTVVert(mHitLD->GetTVEdgeVert(i,0)); ct++; } } } if (ct > 0) { uvw = uvw/(float)ct; mFinalUVW = uvw; mHitLD->SetTVVert(GetCOREInterface()->GetTime(),mHitTVVert,mFinalUVW,mod); mod->NotifyDependents(FOREVER, PART_TEXMAP, REFMSG_CHANGE); mod->InvalidateView(); if (mod->ip) mod->ip->RedrawViews(mod->ip->GetTime()); } } }
bool NzOBJParser::Parse() { NzString matName, meshName; matName = meshName = "default"; m_keepLastLine = false; m_lineCount = 0; m_meshes.clear(); m_mtlLib.Clear(); m_normals.clear(); m_positions.clear(); m_texCoords.clear(); // Beaucoup de meshs font plus de 100 sommets, préparons le terrain m_normals.reserve(100); m_positions.reserve(100); m_texCoords.reserve(100); // On va regrouper les meshs par nom et par matériau std::unordered_map<NzString, std::unordered_map<NzString, std::vector<Face>>> meshes; // On prépare le mesh par défaut std::vector<Face>* currentMesh = &meshes[meshName][matName]; while (Advance(false)) { switch (std::tolower(m_currentLine[0])) { case 'f': // Une face { if (m_currentLine.GetSize() < 7) // Le minimum syndical pour définir une face de trois sommets (f 1 2 3) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING UnrecognizedLine(); #endif break; } unsigned int vertexCount = m_currentLine.Count(' '); if (vertexCount < 3) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING UnrecognizedLine(); #endif break; } Face face; face.vertices.resize(vertexCount); bool error = false; unsigned int pos = 2; for (unsigned int i = 0; i < vertexCount; ++i) { int offset; int& n = face.vertices[i].normal; int& p = face.vertices[i].position; int& t = face.vertices[i].texCoord; if (std::sscanf(&m_currentLine[pos], "%d/%d/%d%n", &p, &t, &n, &offset) != 3) { if (std::sscanf(&m_currentLine[pos], "%d//%d%n", &p, &n, &offset) != 2) { if (std::sscanf(&m_currentLine[pos], "%d/%d%n", &p, &t, &offset) != 2) { if (std::sscanf(&m_currentLine[pos], "%d%n", &p, &offset) != 1) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING UnrecognizedLine(); #endif error = true; break; } else { n = 0; t = 0; } } else n = 0; } else t = 0; } if (p < 0) { p += m_positions.size(); if (p < 0) { Error("Vertex index out of range (" + NzString::Number(p) + " < 0"); error = true; break; } } else p--; if (n < 0) { n += m_normals.size(); if (n < 0) { Error("Vertex index out of range (" + NzString::Number(n) + " < 0"); error = true; break; } } else n--; if (t < 0) { t += m_texCoords.size(); if (t < 0) { Error("Vertex index out of range (" + NzString::Number(t) + " < 0"); error = true; break; } } else t--; if (static_cast<unsigned int>(p) >= m_positions.size()) { Error("Vertex index out of range (" + NzString::Number(p) + " >= " + NzString::Number(m_positions.size()) + ')'); error = true; break; } else if (n >= 0 && static_cast<unsigned int>(n) >= m_normals.size()) { Error("Normal index out of range (" + NzString::Number(n) + " >= " + NzString::Number(m_normals.size()) + ')'); error = true; break; } else if (t >= 0 && static_cast<unsigned int>(t) >= m_texCoords.size()) { Error("TexCoord index out of range (" + NzString::Number(t) + " >= " + NzString::Number(m_texCoords.size()) + ')'); error = true; break; } pos += offset; } if (!error) currentMesh->push_back(std::move(face)); break; } case 'm': #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (m_currentLine.GetWord(0).ToLower() != "mtllib") UnrecognizedLine(); #endif m_mtlLib = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); break; case 'g': case 'o': { if (m_currentLine.GetSize() <= 2 || m_currentLine[1] != ' ') { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING UnrecognizedLine(); #endif break; } NzString objectName = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); if (objectName.IsEmpty()) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING UnrecognizedLine(); #endif break; } meshName = objectName; currentMesh = &meshes[meshName][matName]; break; } #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING case 's': if (m_currentLine.GetSize() <= 2 || m_currentLine[1] == ' ') { NzString param = m_currentLine.SubString(2); if (param != "all" && param != "on" && param != "off" && !param.IsNumber()) UnrecognizedLine(); } else UnrecognizedLine(); break; #endif case 'u': #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING if (m_currentLine.GetWord(0) != "usemtl") UnrecognizedLine(); #endif matName = m_currentLine.SubString(m_currentLine.GetWordPosition(1)); if (matName.IsEmpty()) { #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING UnrecognizedLine(); #endif break; } currentMesh = &meshes[meshName][matName]; break; case 'v': { NzString word = m_currentLine.GetWord(0).ToLower(); if (word == 'v') { NzVector4f vertex(NzVector3f::Zero(), 1.f); unsigned int paramCount = std::sscanf(&m_currentLine[2], "%f %f %f %f", &vertex.x, &vertex.y, &vertex.z, &vertex.w); if (paramCount >= 3) m_positions.push_back(vertex); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else UnrecognizedLine(); #endif } else if (word == "vn") { NzVector3f normal(NzVector3f::Zero()); unsigned int paramCount = std::sscanf(&m_currentLine[3], "%f %f %f", &normal.x, &normal.y, &normal.z); if (paramCount == 3) m_normals.push_back(normal); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else UnrecognizedLine(); #endif } else if (word == "vt") { NzVector3f uvw(NzVector3f::Zero()); unsigned int paramCount = std::sscanf(&m_currentLine[3], "%f %f %f", &uvw.x, &uvw.y, &uvw.z); if (paramCount >= 2) m_texCoords.push_back(uvw); #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else UnrecognizedLine(); #endif } #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING else UnrecognizedLine(); #endif break; } default: #if NAZARA_UTILITY_STRICT_RESOURCE_PARSING UnrecognizedLine(); #endif break; } } std::unordered_map<NzString, unsigned int> materials; unsigned int matCount = 0; for (auto& meshIt : meshes) { for (auto& matIt : meshIt.second) { if (!matIt.second.empty()) { Mesh mesh; mesh.faces = std::move(matIt.second); mesh.name = meshIt.first; auto it = materials.find(matIt.first); if (it == materials.end()) { mesh.material = matCount; materials[matIt.first] = matCount++; } else mesh.material = it->second; m_meshes.push_back(std::move(mesh)); } } } if (m_meshes.empty()) { NazaraError("No meshes"); return false; } m_materials.resize(matCount); for (const std::pair<NzString, unsigned int>& pair : materials) m_materials[pair.second] = pair.first; return true; }
void VolSkin::init( int width, int height, TetMesh *tm ) { this->width = width; this->height = height; tetMesh = tm; // TEMP initialize volume data cudaExtent volumeSize = make_cudaExtent(128, 128, 128); //cudaExtent volumeSize = make_cudaExtent(256, 256, 256); // generate raw volume data float *h_densityData = (float*)malloc( sizeof(float)*volumeSize.width*volumeSize.height*volumeSize.depth ); math::PerlinNoise pn; pn.setDepth( 4 ); pn.setFrequency(3.0f); //pn.setInflection(true); for( int k=0;k<volumeSize.depth;++k ) for( int j=0;j<volumeSize.height;++j ) for( int i=0;i<volumeSize.width;++i ) { int index = k*volumeSize.width*volumeSize.height + j*volumeSize.width + i; math::Vec3f uvw( (float)(i)/(float)(volumeSize.width), (float)(j)/(float)(volumeSize.height), (float)(k)/(float)(volumeSize.depth)); float t = (float)(j)/(float)(volumeSize.height); //h_densityData[index] = 0.5f; //h_densityData[index] = (1.0f-t)*1.0f; h_densityData[index] = std::max( 0.0f, pn.perlinNoise_3D( uvw.x, uvw.y*2.0, uvw.z ) )*1.0f; // cylinder //h_densityData[index] = std::max( 0.0f, pn.perlinNoise_3D( uvw.x*2.0f, uvw.y*2.0f, uvw.z*2.0f ))*1.0f; // tetraeder //h_densityData[index] = (uvw.getLength() < 0.2f ? 1.0f : 0.0f)*2.0f; } // create 3D array d_densityArray = 0; cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<float>(); cudaMalloc3DArray(&d_densityArray, &channelDesc, volumeSize); // copy data to 3D array cudaMemcpy3DParms copyParams = {0}; copyParams.srcPtr = make_cudaPitchedPtr((void*)h_densityData, volumeSize.width*sizeof(float), volumeSize.width, volumeSize.height); copyParams.dstArray = d_densityArray; copyParams.extent = volumeSize; copyParams.kind = cudaMemcpyHostToDevice; cudaMemcpy3D(©Params); // TMP /* h_debugVec.resize( 1000.0f ); d_debugVec = h_debugVec; h_debugInfo.samples = convertToKernel(d_debugVec); h_debugInfo.numSamples = 0; cudaMemcpyToSymbol( d_debugInfo, &h_debugInfo, sizeof(DebugInfo), 0, cudaMemcpyHostToDevice ); */ // setup lighting m_light0.cam = base::CameraPtr( new base::Camera() ); m_light0.cam->m_aspectRatio = 1.0; //m_light0.cam->m_transform = math::createLookAtMatrix( math::Vec3f( -2.0f, -2.0f, 2.0f ), math::Vec3f( 0.0f, 0.0f, 0.0f ), math::Vec3f( 0.0f, 1.0f, 0.0f ), false ); //m_light0.cam->m_transform = math::Matrix44f::TranslationMatrix( 0.3f, 0.15f, 2.0f ); //m_light0.cam->m_transform = math::Matrix44f::TranslationMatrix( -3.0f, 0.0f, 0.0f ); m_light0.cam->m_transform = math::createLookAtMatrix( math::Vec3f( 4.0f, 0.0f, 0.0f ), math::Vec3f( 0.0f, 0.0f, 0.0f ), math::Vec3f( 0.0f, 1.0f, 0.0f ), false ); m_light0.cam->update(); cudaMalloc( &m_light0.d_dctCoefficients, width*height*sizeof(float)*8 );// 8 floats /6 coefficients // set defaults setTotalCrossSection( 10.0f ); setAlbedo( 1.0f ); setAbsorptionColor( math::Vec3f(0.5f,0.5f, 0.5f) ); setScatteringColor(math::Vec3f(0.5f, 0.5f, 0.5f)); setLight(0, math::Vec3f(1.0f, 1.0f, 1.0f), 0.0f); setTime( 0.0f ); setStepSize( 0.01f ); // get tetmesh onto gpu gpuUploadTetMesh(); }
void RigidArmNode :: computeMasterContribution(std::map< DofIDItem, IntArray > &masterDofID, std::map< DofIDItem, FloatArray > &masterContribution) { #if 0 // original implementation without support of different LCS in slave and master int k; IntArray R_uvw(3), uvw(3); FloatArray xyz(3); int numberOfMasterDofs = masterNode->giveNumberOfDofs(); //IntArray countOfMasterDofs((int)masterDofID.size()); // decode of masterMask uvw.at(1) = this->dofidmask->findFirstIndexOf(R_u); uvw.at(2) = this->dofidmask->findFirstIndexOf(R_v); uvw.at(3) = this->dofidmask->findFirstIndexOf(R_w); xyz.beDifferenceOf(*this->giveCoordinates(), *masterNode->giveCoordinates()); if ( hasLocalCS() ) { // LCS is stored as global-to-local, so LCS*xyz_glob = xyz_loc xyz.rotatedWith(* this->localCoordinateSystem, 'n'); } for ( int i = 1; i <= this->dofidmask->giveSize(); i++ ) { Dof *dof = this->giveDofWithID(dofidmask->at(i)); DofIDItem id = dof->giveDofID(); masterDofID [ id ].resize(numberOfMasterDofs); masterContribution [ id ].resize(numberOfMasterDofs); R_uvw.zero(); switch ( masterMask.at(i) ) { case 0: continue; break; case 1: if ( id == D_u ) { if ( uvw.at(2) && masterMask.at( uvw.at(2) ) ) { R_uvw.at(3) = ( ( int ) R_v ); } if ( uvw.at(3) && masterMask.at( uvw.at(3) ) ) { R_uvw.at(2) = -( ( int ) R_w ); } } else if ( id == D_v ) { if ( uvw.at(1) && masterMask.at( uvw.at(1) ) ) { R_uvw.at(3) = -( ( int ) R_u ); } if ( uvw.at(3) && masterMask.at( uvw.at(3) ) ) { R_uvw.at(1) = ( ( int ) R_w ); } } else if ( id == D_w ) { if ( uvw.at(1) && masterMask.at( uvw.at(1) ) ) { R_uvw.at(2) = ( ( int ) R_u ); } if ( uvw.at(2) && masterMask.at( uvw.at(2) ) ) { R_uvw.at(1) = -( ( int ) R_v ); } } break; default: OOFEM_ERROR("unknown value in masterMask"); } //k = ++countOfMasterDofs.at(i); k = 1; masterDofID [ id ].at(k) = ( int ) id; masterContribution [ id ].at(k) = 1.0; for ( int j = 1; j <= 3; j++ ) { if ( R_uvw.at(j) != 0 ) { int sign = R_uvw.at(j) < 0 ? -1 : 1; //k = ++countOfMasterDofs.at(i); k++; masterDofID [ id ].at(k) = sign * R_uvw.at(j); masterContribution [ id ].at(k) = sign * xyz.at(j); } } masterDofID [ id ].resizeWithValues(k); masterContribution [ id ].resizeWithValues(k); } #else // receiver lcs stored in localCoordinateSystem // (this defines the transformation from global to local) FloatArray xyz(3); FloatMatrix TG2L(6,6); // receiver global to receiver local FloatMatrix TR(6,6); // rigid arm transformation between receiver global DOFs and Master global DOFs FloatMatrix TMG2L(6,6); // master global to local FloatMatrix T(6,6); // full transformation for all dofs IntArray fullDofMask = {D_u, D_v, D_w, R_u, R_v, R_w}; bool hasg2l = this->computeL2GTransformation(TG2L, fullDofMask); bool mhasg2l = masterNode->computeL2GTransformation(TMG2L, fullDofMask); xyz.beDifferenceOf(*this->giveCoordinates(), *masterNode->giveCoordinates()); TR.beUnitMatrix(); TR.at(1,5) = xyz.at(3); TR.at(1,6) = -xyz.at(2); TR.at(2,4) = -xyz.at(3); TR.at(2,6) = xyz.at(1); TR.at(3,4) = xyz.at(2); TR.at(3,5) = -xyz.at(1); if (hasg2l && mhasg2l) { FloatMatrix h; h.beTProductOf(TG2L, TR); // T transforms global master DOfs to local dofs; T.beProductOf(h,TMG2L); // Add transformation to master local c.s. } else if (hasg2l) { T.beTProductOf(TG2L, TR); // T transforms global master DOfs to local dofs; } else if (mhasg2l) { T.beProductOf(TR,TMG2L); // Add transformation to master local c.s. } else { T = TR; } // assemble DOF weights for relevant dofs for ( int i = 1; i <= this->dofidmask->giveSize(); i++ ) { Dof *dof = this->giveDofWithID(dofidmask->at(i)); DofIDItem id = dof->giveDofID(); masterDofID [ id ] = *dofidmask; masterContribution [ id ].resize(dofidmask->giveSize()); for (int j = 1; j <= this->dofidmask->giveSize(); j++ ) { masterContribution [ id ].at(j) = T.at(id, dofidmask->at(j)); } } #endif }
void RigidArmNode :: computeMasterContribution() { int k, sign; IntArray R_uvw(3), uvw(3); FloatArray xyz(3); DofIDItem id; // decode of masterMask uvw.at(1) = this->findDofWithDofId(R_u); uvw.at(2) = this->findDofWithDofId(R_v); uvw.at(3) = this->findDofWithDofId(R_w); for ( int i = 1; i <= 3; i++ ) { xyz.at(i) = this->giveCoordinate(i) - masterNode->giveCoordinate(i); } if ( hasLocalCS() ) { // LCS is stored as global-to-local, so LCS*xyz_glob = xyz_loc xyz.rotatedWith(* this->localCoordinateSystem, 'n'); } for ( int i = 1; i <= numberOfDofs; i++ ) { id = this->giveDof(i)->giveDofID(); R_uvw.zero(); switch ( masterMask.at(i) ) { case 0: continue; break; case 1: if ( id == D_u ) { if ( uvw.at(2) && masterMask.at( uvw.at(2) ) ) { R_uvw.at(3) = ( ( int ) R_v ); } if ( uvw.at(3) && masterMask.at( uvw.at(3) ) ) { R_uvw.at(2) = -( ( int ) R_w ); } } else if ( id == D_v ) { if ( uvw.at(1) && masterMask.at( uvw.at(1) ) ) { R_uvw.at(3) = -( ( int ) R_u ); } if ( uvw.at(3) && masterMask.at( uvw.at(3) ) ) { R_uvw.at(1) = ( ( int ) R_w ); } } else if ( id == D_w ) { if ( uvw.at(1) && masterMask.at( uvw.at(1) ) ) { R_uvw.at(2) = ( ( int ) R_u ); } if ( uvw.at(2) && masterMask.at( uvw.at(2) ) ) { R_uvw.at(1) = -( ( int ) R_v ); } } break; default: _error("computeMasterContribution: unknown value in masterMask"); } k = ++ this->countOfMasterDofs->at(i); this->masterDofID [ i - 1 ]->at(k) = ( int ) id; this->masterContribution [ i - 1 ]->at(k) = 1.0; for ( int j = 1; j <= 3; j++ ) { if ( R_uvw.at(j) != 0 ) { sign = R_uvw.at(j) < 0 ? -1 : 1; k = ++ this->countOfMasterDofs->at(i); this->masterDofID [ i - 1 ]->at(k) = sign * R_uvw.at(j); this->masterContribution [ i - 1 ]->at(k) = sign * xyz.at(j); } } } }
void MainWindow::modifieruv(){ modifUVwindow uvw(fac); if (uvw.exec()){ fillMainWindow(); } }