本文整理汇总了C++中Facet::volume方法的典型用法代码示例。如果您正苦于以下问题:C++ Facet::volume方法的具体用法?C++ Facet::volume怎么用?C++ Facet::volume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facet
的用法示例。
在下文中一共展示了Facet::volume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Vertex
bool ConvexHull3D::remakeHull(Vertex *point, vector<Edge *> &horizonEdges, const vector<Facet *> &visibleFacets, std::vector<Vertex*> &nearPoints)
{
Vector3D centre;
for(unsigned int i = 0; i < vertices.size(); i++)
centre += vertices[i]->position;
centre /= vertices.size();
vector<Facet *> createdFacets;
Vertex *newVertex = new Vertex(point->position, vertices.size());
Facet *last = 0, *first = 0;
std::vector<int> valids(horizonEdges.size(), 0);
for(unsigned int i = 0; i < horizonEdges.size(); i++)
{
Edge *e = horizonEdges[i];
Facet *f = new Facet(newVertex, e->end, e->start, facets.size()+i);
createdFacets.push_back(f);
double dd = -f->volume(centre);
if(!(f->wellFormed) || dd > 0)
{
double d = e->distanceToLine(point->position);
double ed = e->projectToLine(point->position);
double ed1 = e->next->projectToLine(point->position);
double ed2 = e->prev->projectToLine(point->position);
std::cout << "problem with point " << point->index << ": " << point->position << endl;
std::cout << newVertex->position << std::endl;
std::cout << e->end->position << std::endl;
std::cout << e->start->position << std::endl;
std::cout << "volume = " << f->volume(centre) << endl;
valids[i] = 1;
Vector3D::normal(newVertex->position, e->end->position, e->start->position);
}
}
if(std::accumulate(valids.begin(), valids.end(), 0) > 0)
{
for(unsigned int j = 0; j < createdFacets.size(); j++)
delete createdFacets[j];
delete newVertex;
return false;
}
vertices.push_back(newVertex); //all facets are well formed , add new vertex to list
for(unsigned int i = 0; i < horizonEdges.size(); i++)
{
Edge *e = horizonEdges[i];
Facet *f = createdFacets[i];
facets.push_back(f);
if(!(f->edges[1]->connect(e)))
{
cout << "D'oh, error trying to connect to horizon edges" << endl;
exit(1);
}
if(last != 0)
{
// horizon edges are colllcted in clockwise order
if(!(f->edges[2]->connect(last->edges[0])))
{
cout << "D'oh, error trying to connect to to last faces" << endl;
exit(1);
}
}
last = f;
if(first == 0) first = f;
}
if(last != 0 && first != 0)
{
if(!(last->edges[0]->connect(first->edges[2])))
{
cout << "D'oh, error trying to connect two end of loops" << endl;
exit(1);
}
}
else
{
cout << "Fatal hull making algorithm error!" << endl;
exit(1);
}
//this updates the outside set of new facets
for(unsigned int f = 0; f < visibleFacets.size(); f++)
{
Facet::updateOutsideSets(createdFacets, visibleFacets[f]->outsideSet, eps);
// retain undecided points
nearPoints.insert(nearPoints.end(), visibleFacets[f]->outsideSet.begin(), visibleFacets[f]->outsideSet.end());
visibleFacets[f]->outsideSet.clear();
//.........这里部分代码省略.........