MStatus MVGMesh::unsetAllBlindData() const { MStatus status; // Get all vertices MItMeshVertex vIt(_dagpath, MObject::kNullObj, &status); vIt.updateSurface(); vIt.geomChanged(); MIntArray componentId; while(!vIt.isDone()) { const int index = vIt.index(&status); componentId.append(index); vIt.next(); } MVGEditCmd* cmd = new MVGEditCmd(); if(cmd) { cmd->clearBD(_dagpath, componentId); MArgList args; if(cmd->doIt(args)) cmd->finalize(); } delete cmd; return status; }
VDPMLoader::~VDPMLoader(){ this->qFilename_.clear(); this->mesh_loaded = false; vsplit_loaded.clear(); vfront_.clear(); vhierarchy_.clear(); index2handle_map.clear(); //mesh_.clear(); VDPMMesh::FaceIter fIt(mesh_.faces_begin()), fEnd(mesh_.faces_end()); for(; fIt != fEnd; ++fIt){ mesh_.delete_face(fIt.handle()); } VDPMMesh::VertexIter vIt(mesh_.vertices_begin()), vEnd(mesh_.vertices_end()); for(; vIt != vEnd; ++vIt){ mesh_.delete_vertex(vIt.handle()); } mesh_.garbage_collection(); if(base_info_data != NULL){ delete [] base_info_data; base_info_data = NULL; } base_info_data_size = 0; }
void SourceByASTPrinter::visitBlockNodeWithoutBraces(BlockNode *node){ Scope::VarIterator vIt(node->scope()); while(vIt.hasNext()) { AstVar *var = vIt.next(); cout<<typeToName(var->type())<<" "<< var->name()<< ";"<<endl; } Scope::FunctionIterator fIt(node->scope()); while(fIt.hasNext()) { fIt.next()->node()->visit(this); } int nodesNumber = node->nodes(); for (int i = 0; i < nodesNumber; ++i) { AstNode *nodeAt = node->nodeAt(i); nodeAt->visit(this); if(!nodeAt->isForNode() && !nodeAt->isIfNode() && !nodeAt->isWhileNode()) cout<<";"<<endl; } }
void MeshView::drawMesh( DRAW_MODE d ) { if( m_meshPtr ) { std::cout << "MeshView::drawMesh()" << std::endl; m_meshPtr->lock(); Mesh::ConstFaceIter fIt(m_meshPtr->faces_begin()), fEnd(m_meshPtr->faces_end()); Mesh::ConstFaceVertexIter fvIt; Mesh::ConstVertexIter vIt(m_meshPtr->vertices_begin()); float color[4] = { 1.0, 1.0, 1.0, 1.0 }; switch( d ) { case POINTS_ONLY: glBegin(GL_POINTS); glColor3fv(color); for(; vIt!=m_meshPtr->vertices_end(); ++vIt) { if( prepareColor( color, m_meshPtr->color(vIt) ) ) glColor3fv(color); glVertex3dv(m_meshPtr->point(vIt)); } glEnd(); break; case WIREFRAME: for (; fIt!=fEnd; ++fIt) { glBegin(GL_LINE_STRIP); glColor3fv(color); fvIt = m_meshPtr->cfv_iter(fIt.handle()); if( prepareColor( color, m_meshPtr->color(fvIt) ) ) glColor3fv(color); glVertex3dv(m_meshPtr->point(fvIt)); ++fvIt; if( prepareColor( color, m_meshPtr->color(fvIt) ) ) glColor3fv(color); glVertex3dv(m_meshPtr->point(fvIt)); ++fvIt; if( prepareColor( color, m_meshPtr->color(fvIt) ) ) glColor3fv(color); glVertex3dv(m_meshPtr->point(fvIt)); glEnd(); } break; case FACETS: case FLAT_FACET: glBegin(GL_TRIANGLES); glColor3fv(color); for (; fIt!=fEnd; ++fIt) { glNormal3fv( m_meshPtr->normal( fIt.handle() ) ); fvIt = m_meshPtr->cfv_iter(fIt.handle()); if( prepareColor( color, m_meshPtr->color(fvIt) ) ) glColor3fv(color); glVertex3dv(m_meshPtr->point(fvIt)); ++fvIt; if( prepareColor( color, m_meshPtr->color(fvIt) ) ) glColor3fv(color); glVertex3dv(m_meshPtr->point(fvIt)); ++fvIt; if( prepareColor( color, m_meshPtr->color(fvIt) ) ) glColor3fv(color); glVertex3dv(m_meshPtr->point(fvIt)); } glEnd(); break; case SMOOTH_FACET: glBegin(GL_TRIANGLES); glColor3fv(color); for (; fIt!=fEnd; ++fIt) { fvIt = m_meshPtr->cfv_iter(fIt.handle()); glNormal3fv(m_meshPtr->normal(fvIt.handle()) ); if( prepareColor( color, m_meshPtr->color(fvIt) ) ) glColor3fv(color); glVertex3dv(m_meshPtr->point(fvIt)); ++fvIt; glNormal3fv(m_meshPtr->normal(fvIt.handle())); if( prepareColor( color, m_meshPtr->color(fvIt) ) ) glColor3fv(color); glVertex3dv(m_meshPtr->point(fvIt)); ++fvIt; glNormal3fv(m_meshPtr->normal(fvIt.handle())); if( prepareColor( color, m_meshPtr->color(fvIt) ) ) glColor3fv(color); glVertex3dv(m_meshPtr->point(fvIt)); } glEnd(); break; default: break; } //glFlush(); m_meshPtr->unlock(); setDirty(false); //std::cout << " } MeshView::drawMesh()" << std::endl; } }
void VDPMLoader::openVDPM_ServerRendering(const char *_filename) { unsigned int i; unsigned int value; unsigned int fvi[3]; char fileformat[16]; Vec3f p, normal; float radius, sin_square, mue_square, sigma_square; VHierarchyNodeHandleContainer roots; VertexHandle vertex_handle; VHierarchyNodeIndex node_index; VHierarchyNodeIndex lchild_node_index, rchild_node_index; VHierarchyNodeIndex fund_lcut_index, fund_rcut_index; VHierarchyNodeHandle node_handle; VHierarchyNodeHandle lchild_node_handle, rchild_node_handle; std::ifstream ifs(_filename, std::ios::binary); if (!ifs) { std::cerr << "read error\n"; exit(1); } // bool swap = Endian::local() != Endian::LSB; // read header ifs.read(fileformat, 10); fileformat[10] = '\0'; if (std::string(fileformat) != std::string("VDProgMesh")) { std::cerr << "Wrong file format.\n"; ifs.close(); exit(1); } IO::restore(ifs, n_base_vertices_, swap); IO::restore(ifs, n_base_faces_, swap); IO::restore(ifs, n_details_, swap); mesh_.clear(); vfront_.clear(); vhierarchy_.clear(); vhierarchy_.set_num_roots(n_base_vertices_); // load base mesh for (i=0; i<n_base_vertices_; ++i) { IO::restore(ifs, p, swap); IO::restore(ifs, radius, swap); IO::restore(ifs, normal, swap); IO::restore(ifs, sin_square, swap); IO::restore(ifs, mue_square, swap); IO::restore(ifs, sigma_square, swap); vertex_handle = mesh_.add_vertex(p); node_index = vhierarchy_.generate_node_index(i, 1); node_handle = vhierarchy_.add_node(); VHierarchyNode &node = vhierarchy_.node(node_handle); node.set_index(node_index); node.set_vertex_handle(vertex_handle); mesh_.data(vertex_handle).set_vhierarchy_node_handle(node_handle); node.set_radius(radius); node.set_normal(normal); node.set_sin_square(sin_square); node.set_mue_square(mue_square); node.set_sigma_square(sigma_square); mesh_.set_normal(vertex_handle, normal); index2handle_map[node_index] = node_handle; roots.push_back(node_handle); } vfront_.init(roots, n_details_); for (i=0; i<n_base_faces_; ++i) { IO::restore(ifs, fvi[0], swap); IO::restore(ifs, fvi[1], swap); IO::restore(ifs, fvi[2], swap); mesh_.add_face(mesh_.vertex_handle(fvi[0]), mesh_.vertex_handle(fvi[1]), mesh_.vertex_handle(fvi[2])); } vsplit_loaded.clear(); // load details for (i=0; i<n_details_; ++i) { Vsplit avs; // position of v0 IO::restore(ifs, p, swap); avs.v0 = p; // vsplit info. IO::restore(ifs, value, swap); node_index = VHierarchyNodeIndex(value); avs.node_index = value; IO::restore(ifs, value, swap); fund_lcut_index = VHierarchyNodeIndex(value); avs.fund_lcut_index = value; IO::restore(ifs, value, swap); fund_rcut_index = VHierarchyNodeIndex(value); avs.fund_rcut_index = value; node_handle = index2handle_map[node_index]; vhierarchy_.make_children(node_handle); VHierarchyNode &node = vhierarchy_.node(node_handle); VHierarchyNode &lchild = vhierarchy_.node(node.lchild_handle()); VHierarchyNode &rchild = vhierarchy_.node(node.rchild_handle()); node.set_fund_lcut(fund_lcut_index); node.set_fund_rcut(fund_rcut_index); vertex_handle = mesh_.add_vertex(p); lchild.set_vertex_handle(vertex_handle); rchild.set_vertex_handle(node.vertex_handle()); index2handle_map[lchild.node_index()] = node.lchild_handle(); index2handle_map[rchild.node_index()] = node.rchild_handle(); // view-dependent parameters IO::restore(ifs, radius, swap); IO::restore(ifs, normal, swap); IO::restore(ifs, sin_square, swap); IO::restore(ifs, mue_square, swap); IO::restore(ifs, sigma_square, swap); lchild.set_radius(radius); lchild.set_normal(normal); lchild.set_sin_square(sin_square); lchild.set_mue_square(mue_square); lchild.set_sigma_square(sigma_square); avs.l_radius = radius; avs.l_normal = normal; avs.l_mue_square = mue_square; avs.l_sigma_square = sigma_square; avs.l_sin_square = sin_square; IO::restore(ifs, radius, swap); IO::restore(ifs, normal, swap); IO::restore(ifs, sin_square, swap); IO::restore(ifs, mue_square, swap); IO::restore(ifs, sigma_square, swap); rchild.set_radius(radius); rchild.set_normal(normal); rchild.set_sin_square(sin_square); rchild.set_mue_square(mue_square); rchild.set_sigma_square(sigma_square); avs.r_radius = radius; avs.r_normal = normal; avs.r_mue_square = mue_square; avs.r_sigma_square = sigma_square; avs.r_sin_square = sin_square; vsplit_loaded.push_back(avs); } ifs.close(); //refine 100 vsplits int cc = 0; for ( vfront_.begin(); !vfront_.end() && cc < 100; ++cc) { VHierarchyNodeHandle node_handle = vfront_.node_handle(); if (vhierarchy_.is_leaf_node(node_handle) != true) { force_vsplit(node_handle, vsplits_to_send); } vfront_.next(); std::cout << "vfront_ size " << vfront_.size() <<std::endl; } //**********// // update face and vertex normals mesh_.update_face_normals(); // bounding box VDPMMesh::ConstVertexIter vIt(mesh_.vertices_begin()), vEnd(mesh_.vertices_end()); VDPMMesh::Point bbMin, bbMax; bbMin = bbMax = mesh_.point(vIt); for (; vIt!=vEnd; ++vIt) { bbMin.minimize(mesh_.point(vIt)); bbMax.maximize(mesh_.point(vIt)); } // set center and radius VDPMMesh::Point center = 0.5f * (bbMin + bbMax); set_scene_pos(0.5f*(bbMin + bbMax), 0.5*(bbMin - bbMax).norm()); // info std::cerr << mesh_.n_vertices() << " vertices, " << mesh_.n_edges() << " edge, " << mesh_.n_faces() << " faces, " << n_details_ << " detail vertices\n"; mesh_loaded = true; }