static void getAllParameters(MVertex *v, GFace *gf, std::vector<SPoint2> ¶ms) { params.clear(); if (gf->geomType() == GEntity::CompoundSurface ){ GFaceCompound *gfc = (GFaceCompound*) gf; params.push_back(gfc->parFromVertex(v)); return; } if(v->onWhat()->dim() == 0){ GVertex *gv = (GVertex*)v->onWhat(); std::list<GEdge*> ed = gv->edges(); bool seam = false; for(std::list<GEdge*>::iterator it = ed.begin(); it != ed.end(); it++){ if((*it)->isSeam(gf)) { Range<double> range = (*it)->parBounds(0); if (gv == (*it)->getBeginVertex()){ params.push_back((*it)->reparamOnFace(gf, range.low(),-1)); params.push_back((*it)->reparamOnFace(gf, range.low(), 1)); } if (gv == (*it)->getEndVertex()){ params.push_back((*it)->reparamOnFace(gf, range.high(),-1)); params.push_back((*it)->reparamOnFace(gf, range.high(), 1)); } if (gv != (*it)->getBeginVertex() && gv != (*it)->getEndVertex()){ Msg::Warning("Strange!"); } seam = true; } } if (!seam) params.push_back(gv->reparamOnFace(gf, 1)); } else if(v->onWhat()->dim() == 1){ GEdge *ge = (GEdge*)v->onWhat(); if(!ge->haveParametrization()) return; double UU; v->getParameter(0, UU); if (UU == 0.0) UU = ge->parFromPoint(v->point()); params.push_back(ge->reparamOnFace(gf, UU, 1)); if(ge->isSeam(gf)) params.push_back(ge->reparamOnFace(gf, UU, -1)); } else{ double UU, VV; if(v->onWhat() == gf && v->getParameter(0, UU) && v->getParameter(1, VV)) params.push_back(SPoint2(UU, VV)); } }
bool reparamMeshVertexOnFace(MVertex *v, const GFace *gf, SPoint2 ¶m, bool onSurface) { if (gf->geomType() == GEntity::CompoundSurface ){ GFaceCompound *gfc = (GFaceCompound*) gf; param = gfc->parFromVertex(v); return true; } if(v->onWhat()->geomType() == GEntity::DiscreteCurve || v->onWhat()->geomType() == GEntity::BoundaryLayerCurve){ param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z()), onSurface); return true; } if(v->onWhat()->dim() == 0){ GVertex *gv = (GVertex*)v->onWhat(); // hack for bug in periodic curves if (gv->getNativeType() == GEntity::GmshModel && gf->geomType() == GEntity::Plane) param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z()), onSurface); else param = gv->reparamOnFace(gf, 1); // shout, we could be on a seam std::list<GEdge*> ed = gv->edges(); for(std::list<GEdge*>::iterator it = ed.begin(); it != ed.end(); it++) if((*it)->isSeam(gf)) return false; } else if(v->onWhat()->dim() == 1){ GEdge *ge = (GEdge*)v->onWhat(); double t; v->getParameter(0, t); param = ge->reparamOnFace(gf, t, 1); if(!v->getParameter(0,t)) { Msg::Error("Vertex %p not MEdgeVertex", v); return false; //param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z()), onSurface); } // shout, we are on a seam if(ge->isSeam(gf)) return false; } else{ double uu, vv; if(v->onWhat() == gf && v->getParameter(0, uu) && v->getParameter(1, vv)){ param = SPoint2(uu, vv); } else { // brute force! param = gf->parFromPoint(SPoint3(v->x(), v->y(), v->z()), onSurface); } } return true; }