void drawContext::drawMesh() { if(!CTX::instance()->mesh.draw) return; // make sure to flag any model-dependent post-processing view as // changed if the underlying mesh has, before resetting the changed // flag if(CTX::instance()->mesh.changed){ for(unsigned int i = 0; i < GModel::list.size(); i++) for(unsigned int j = 0; j < PView::list.size(); j++) if(PView::list[j]->getData()->hasModel(GModel::list[i])) PView::list[j]->setChanged(true); } glPointSize((float)CTX::instance()->mesh.pointSize); gl2psPointSize((float)(CTX::instance()->mesh.pointSize * CTX::instance()->print.epsPointSizeFactor)); glLineWidth((float)CTX::instance()->mesh.lineWidth); gl2psLineWidth((float)(CTX::instance()->mesh.lineWidth * CTX::instance()->print.epsLineWidthFactor)); if(CTX::instance()->mesh.lightTwoSide) glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); else glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); if(!CTX::instance()->clipWholeElements){ for(int i = 0; i < 6; i++) if(CTX::instance()->mesh.clip & (1 << i)) glEnable((GLenum)(GL_CLIP_PLANE0 + i)); else glDisable((GLenum)(GL_CLIP_PLANE0 + i)); } for(unsigned int i = 0; i < GModel::list.size(); i++){ GModel *m = GModel::list[i]; m->fillVertexArrays(); if(m->getVisibility() && isVisible(m)){ int status = m->getMeshStatus(); if(status >= 0) std::for_each(m->firstVertex(), m->lastVertex(), drawMeshGVertex(this)); if(status >= 1) std::for_each(m->firstEdge(), m->lastEdge(), drawMeshGEdge(this)); if(status >= 2){ beginFakeTransparency(); std::for_each(m->firstFace(), m->lastFace(), drawMeshGFace(this)); endFakeTransparency(); } if(status >= 3) std::for_each(m->firstRegion(), m->lastRegion(), drawMeshGRegion(this)); } } CTX::instance()->mesh.changed = 0; for(int i = 0; i < 6; i++) glDisable((GLenum)(GL_CLIP_PLANE0 + i)); }
void Filler::treat_model(){ GRegion* gr; GModel* model = GModel::current(); GModel::riter it; for(it=model->firstRegion();it!=model->lastRegion();it++) { gr = *it; if(gr->getNumMeshElements()>0){ treat_region(gr); } } }
// The function that tests whether a surface is a QuadToTri top surface and whether // there are conflicts. If surface is not a top for a valid QuadToTri region or if // there are QuadToTri conflicts, return 0. // if the surface turns out to be the source of a toroidal loop extrusion (which will then // NOT have geo.Mode == COPIED_ENTITY), return 2 (this will require special meshing considerations). // Note that RemoveDuplicateSurfaces() makes this DIFFICULT. // Also, the type of QuadToTri interface is placed into the // pointer argument quadToTri. . // Added 2010-12-09. int IsValidQuadToTriTop(GFace *face, int *quadToTri, bool *detectQuadToTriTop) { (*quadToTri) = NO_QUADTRI; (*detectQuadToTriTop) = false; int is_toroidal_quadtri = 0; GModel *model = face->model(); // First thing is first: determine if this is a toroidal quadtri extrusion. if so, can skip the rest // It seems the member pointers to neighboring regions for extruded top faces are not set. // For now, have to loop through // ALL the regions to see if the presently considered face belongs to the region. // The following loop will find all the regions that the face bounds, and determine // whether the face is a top face of the region (including whether the region is even extruded). // After that information is determined, function can test for QuadToTri neighbor conflicts. // first determine if this is toroidal quadtotri is_toroidal_quadtri = IsInToroidalQuadToTri(face); if( is_toroidal_quadtri ) (*detectQuadToTriTop) = true; else{ std::vector<GRegion *> top_regions; std::vector<GRegion *> adjacent_regions; std::vector<GRegion *> all_regions; int numRegions = 0; int numTopRegions = 0; std::set<GRegion *, GEntityLessThan>::iterator itreg; for( itreg = model->firstRegion(); itreg != model->lastRegion(); itreg++ ) all_regions.push_back( (*itreg) ); for(unsigned int i_reg = 0; i_reg < all_regions.size(); i_reg++ ){ // save time if( numRegions >= 2 ) break; GRegion *region = all_regions[i_reg]; // is region in the current model's regions or is it deleted? if( !FindVolume( ( region->tag() ) ) ) continue; // does face belong to region? std::list<GFace *> region_faces = std::list<GFace *>( region->faces() ); if( std::find( region_faces.begin(), region_faces.end(), face ) != region_faces.end() ){ adjacent_regions.push_back(region); numRegions++; } else continue; // is region a structured extruded? if( !(region->meshAttributes.extrude && region->meshAttributes.extrude->mesh.ExtrudeMesh && region->meshAttributes.extrude->geo.Mode == EXTRUDED_ENTITY) ) continue; // Test whether the face is a top for the region if( IsSurfaceATopForRegion(region, face) ){ top_regions.push_back(region); numTopRegions++; if( region->meshAttributes.extrude->mesh.QuadToTri ) (*detectQuadToTriTop) = true; } } // MAIN test of whether this is even a quadToTri extrusion lateral // the only return 0 path that is NOT an error if( !(*detectQuadToTriTop) ) return 0; ExtrudeParams *ep = face->meshAttributes.extrude; if(!ep && !is_toroidal_quadtri){ Msg::Error("In IsValidQuadToTriTop(), no extrude info for surface %d.", face->tag() ); return 0; } if( ep->geo.Mode != COPIED_ENTITY ){ Msg::Error("In IsValidQuadToTriTop(), surface %d is not copied from source.", face->tag() ); return 0; } if( ep->mesh.QuadToTri == 0){ Msg::Error("In IsValidQuadToTriTop(), surface %d was determined to be the top surface " "for a QuadToTri extrusion, but does not have QuadToTri parameters set within itself.", face->tag() ); return 0; } GFace *face_source = model->getFaceByTag(std::abs(ep->geo.Source)); if(!face_source){ Msg::Error("In IsValidQuadToTriTop(), unknown source face number %d.", face->meshAttributes.extrude->geo.Source); return 0; } if(numRegions > 2){ Msg::Error("In IsValidQuadToTriTop(), too many regions adjacent to surface %d.", face->tag() ); return 0; } if( top_regions.size() ){ (*quadToTri) = top_regions[0]->meshAttributes.extrude->mesh.QuadToTri; } // Make sure that face is the top for only one region. if not, then there will likely // be conflicts (two regions extruded into each other). if( top_regions.size() > 1 ){ Msg::Error("In IsValidQuadToTriTop(), QuadToTri top surface %d identified as top " "surface for more than one region. Likely conflict.", face->tag() ); return 0; } } // end of else that executes if NOT toroidal extrusion // this is technically redundant...but if changes are made, it's good to keep this here at the end for safety if( !(*detectQuadToTriTop) ) return 0; if( !is_toroidal_quadtri ) return 1; else if( is_toroidal_quadtri == 1 ) { return 2;} // for toroidal extrusion else return 3; }