Select Git revision
Forked from
gmsh / gmsh
Source project has a limited visibility.
GEdgeCompound.cpp 9.49 KiB
// Gmsh - Copyright (C) 1997-2016 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@onelab.info>.
//
// Contributor(s):
// Emilie Marchandise
//
#include <stdlib.h>
#include "GmshConfig.h"
#include "GEdgeCompound.h"
#include "discreteEdge.h"
#include "Numeric.h"
#include "Curvature.h"
static bool looksOk(int tag, std::vector<GEdge*> &compound)
{
if(compound.empty()){
Msg::Error("Empty edge compound %d", tag);
return false;
}
for(unsigned int i = 0; i < compound.size(); i++){
if(!compound[i]->getBeginVertex() || !compound[i]->getEndVertex()){
Msg::Error("Edge compound %d with missing begin/end vertex", tag);
return false;
}
if(compound.size() > 1 && compound[i]->getBeginVertex() == compound[i]->getEndVertex()){
Msg::Warning("Edge compound %d with subloop", tag);
return true;
}
}
return true;
}
GEdgeCompound::GEdgeCompound(GModel *m, int tag, std::vector<GEdge*> &compound,
std::vector<int> &orientation)
: GEdge(m, tag, 0, 0), _compound(compound), _orientation(orientation)
{
if(!looksOk(tag, compound)) return;
int N = _compound.size();
if(N == (int)_orientation.size()){
v0 = _orientation[0] ? _compound[0]->getBeginVertex() : _compound[0]->getEndVertex();
v1 = _orientation[N-1] ? _compound[N-1]->getEndVertex() : _compound[N-1]->getBeginVertex();
v0->addEdge(this);
v1->addEdge(this);
}
else{
Msg::Error("Wrong input data for compound edge %d", tag);
return;
}
for (unsigned int i = 0; i < _compound.size(); i++)
_compound[i]->setCompound(this);
for(std::vector<GEdge*>::iterator it = _compound.begin(); it != _compound.end(); ++it){
if(!(*it)){
Msg::Error("Incorrect edge in compound edge %d", tag);
return;
}
}
parametrize();
}
GEdgeCompound::GEdgeCompound(GModel *m, int tag, std::vector<GEdge*> &compound)
: GEdge(m, tag, 0 , 0), _compound(compound)
{
if(!looksOk(tag, compound)) return;