本文整理汇总了C++中TriangleList类的典型用法代码示例。如果您正苦于以下问题:C++ TriangleList类的具体用法?C++ TriangleList怎么用?C++ TriangleList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TriangleList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSurroundingTriangles
TriangleList getSurroundingTriangles(QPointF *points, quint32 size, quint32 layers,
Vertex v, QPointF *centerPtr) {
TriangleList result;
if (!v.layer) {
for (quint32 i = 0; i < size; ++i)
result.append(TRIANGLE(0, i, 0));
return result;
}
// inner part
result.append(TRIANGLE(v.layer - 1, v.sector, 2 * v.index));
if (v.index) {
result.append(TRIANGLE(v.layer - 1, v.sector, 2 * v.index - 1));
result.append(TRIANGLE(v.layer - 1, v.sector, 2 * v.index - 2));
} else
result.append(TRIANGLE(v.layer - 1, (v.sector + size - 1) % size, 2 * v.layer - 2));
// outer part
if (v.layer < layers) {
result.append(TRIANGLE(v.layer, v.sector, 2 * v.index));
result.append(TRIANGLE(v.layer, v.sector, 2 * v.index + 1));
if (v.index) {
result.append(TRIANGLE(v.layer, v.sector, 2 * v.index - 1));
} else {
result.append(TRIANGLE(v.layer, (v.sector + size - 1) % size, 2 * v.layer - 1));
result.append(TRIANGLE(v.layer, (v.sector + size - 1) % size, 2 * v.layer));
}
}
return result;
}
示例2: groupedSliderChangedSlot
// groupedSliders are in the upper set of sliders
void TriangleDensityWidget::groupedSliderChangedSlot(int value)
{
TriangleList triangles = triangleScene->triangles();
double norm = getNorm();
triangles.at(grouped_slider_idx)->xform()->density
= (double)value / 1000. * norm;
resetSliders(norm);
emit dataChanged();
}
示例3: phiFunction
double phiFunction(QPointF *points, quint32 size, quint32 layers,
QPointF point, quint32 vertexNumber, QPointF *centerPtr) {
Vertex vertex = getVertex(size, vertexNumber);
TriangleList triangles = getSurroundingTriangles(points, size,
layers, vertex, centerPtr);
for (int i = 0; i < triangles.size(); ++i) {
if (pointInTriangle(point, triangles.at(i)))
return phiFunction(point, triangles.at(i),
getPoint(points, size, layers, vertex, centerPtr));
}
return 0;
}
示例4: lambda
Deform::Deform(const float *P_data, int P_Num, const AdjList &adj_list, const TriangleList &triangle_list)
:at(ORIGIN_HARD),
P_data(P_data),
P_Num(P_Num),
max_iter(10),
min_tol(1e-3),
lambda(5),
adj_list(adj_list)
{
for (size_t i = 0, i_end = triangle_list.size(); i < i_end; ++ i)
{
std::vector<int> face = triangle_list[i];
std::sort(face.begin(), face.end());
assert(face.size() == 3);
face_list.push_back(Eigen::Vector3i(face[0], face[1], face[2]));
}
P.resize(3, P_Num);
for (int i = 0; i != P_Num; ++i) {P.col(i) << P_data[3*i], P_data[3*i+1], P_data[3*i+2];}
P_Prime = P;
R = vector<Matrix3f>(P_Num, Matrix3f::Identity());
// Weight
build_weight_matrix();
}
示例5: FindNeighbors
void MeshMender::FindNeighbors(Triangle* tri,
TriangleList&possibleNeighbors,
Triangle** neighbor1,
Triangle** neighbor2,
std::vector< Vertex >& theVerts)
{
*neighbor1 = NULL;
*neighbor2 = NULL;
std::vector<Triangle*> theNeighbors;
for(unsigned int n = 0; n < possibleNeighbors.size(); ++n)
{
TriID tID = possibleNeighbors[n];
Triangle* possible =&(m_Triangles[ tID]);
if(possible != tri ) //check for myself
{
if( SharesEdge(tri, possible, theVerts) )
{
theNeighbors.push_back(possible);
}
}
}
if(theNeighbors.size()>0)
*neighbor1 = theNeighbors[0];
if(theNeighbors.size()>1)
*neighbor2 = theNeighbors[1];
}
示例6: generateEventList
void KDTree::generateEventList( TriangleList& triList, AABB& parentBox )
{
//Start with an empty event list
eventList.clear();
//Go through all the triangles passed in.
for(unsigned i = 0; i < triList.size(); ++i)
{
//Clip the triangle to the parent box
Triangle tri = triList[i];
clipTriToParentBox(tri, parentBox);
//And the box be the AABB of this event
AABB* pBox = &parentBox;
//Grab the minimum and maximum points of the triangle as per this split axis
float pMin = GeometryLibrary::minPos(tri, curAxis);
float pMax = GeometryLibrary::maxPos(tri, curAxis);
//If the maximum and minimum points are the same, we have a coplanar event
if(pMax == pMin)
eventList.push_back(KDEvent(Coplanar, &tri, pMin, pBox));
//Otherwise start at the minimum and end at the maximum on this axis
else
{
eventList.push_back(KDEvent(Starting, &tri, pMin, pBox));
eventList.push_back(KDEvent(Ending, &tri, pMax, pBox));
}
}
//Sort according to the operator < provided so that the events are in ascending order
std::sort(eventList.begin(), eventList.end());
}
示例7: check_triangle
bool Triangulator::check_triangle(Vertex *first, TriangleList &triangles) {
// path is a dot
if (first->next == first)
return true;
// path is a two lines
if (first->next->next == first)
return true;
// path is triangle
if (first->next->next->next == first) {
triangles.push_back(first->index);
triangles.push_back(first->next->index);
triangles.push_back(first->next->next->index);
return true;
}
return false;
}
示例8: reset
void TriangleDensityWidget::reset()
{
TriangleList triangles = triangleScene->triangles();
// make more sliders if necessary
while (sliders.size() < triangles.size())
{
GroupedSlider* s
= new GroupedSlider(Qt::Horizontal, this, sliders.size());
QLabel* name = new QLabel(QString::number(sliders.size() + 1));
QHBoxLayout* hl = new QHBoxLayout();
hl->addWidget(name);
hl->addWidget(s);
dynamic_cast<QVBoxLayout*>
(m_scrollAreaWidgetContents->layout())->insertLayout(-1,hl,0);
s->setRange(0, 1000);
s->setVisible(false);
sliders.append(s);
slider_names.append(name);
connect(s, SIGNAL(valueChanged(int)), this, SLOT(groupedSliderChangedSlot(int)));
connect(s, SIGNAL(sliderPressed()), this, SLOT(groupedSliderPressedSlot()));
connect(s, SIGNAL(undoStateSignal()), this, SIGNAL(undoStateSignal()));
}
// hide non-used sliders
for (int n = triangles.size() ; n < sliders.size() ; n++)
{
sliders.at(n)->setVisible(false);
slider_names.at(n)->setVisible(false);
}
resetSliders(getNorm());
QStringList items;
items << tr("None");
for (int n = 1 ; n <= genome->size() ; n++)
items << QString::number(n);
int n = m_crossComboBox->currentIndex();
m_crossComboBox->blockSignals(true);
m_crossComboBox->clear();
m_crossComboBox->addItems(items);
m_crossComboBox->setCurrentIndex(n);
m_crossComboBox->blockSignals(false);
}
示例9: triangle_tree
void triangle_tree(
const Eigen::MatrixXd & V,
const Eigen::MatrixXi & F,
TriTree & tree,
TriangleList & tlist)
{
assert(F.cols() == 3);
tlist.clear();
// Loop over facets
for(int f = 0;f<F.rows();f++)
{
Point3 a(V(F(f,0),0), V(F(f,0),1), V(F(f,0),2));
Point3 b(V(F(f,1),0), V(F(f,1),1), V(F(f,1),2));
Point3 c(V(F(f,2),0), V(F(f,2),1), V(F(f,2),2));
tlist.push_back(Triangle3( a,b,c));
}
// constructs AABB tree
tree.clear();
tree.insert(tlist.begin(),tlist.end());
}
示例10: splitTriList
void KDTree::splitTriList( TriangleList& l, TriangleList& r, TriangleList& p, float pos )
{
curAxis = splitAxis;
unsigned left, right, coplanar, side;
//Go through every triangle in the triangle list
for(unsigned i = 0; i < p.size(); ++i)
{
Triangle& tri = p[i];
left = right = coplanar = 0;
CountVertPositions(tri, left, right, coplanar, splitAxis, pos);
side = max(left, max(right, coplanar));
if(side == left)
l.push_back(tri);
else if(side == right)
r.push_back(tri);
else if(side == coplanar)
l.push_back(tri);
}
}
示例11: findMinPlane
void KDTree::findMinPlane(TriangleList& triList, AABB& parentBox)
{
unsigned Nl, Nr, Nc, Vs, Ve, Vc;
Vs = Ve = Vc = 0;
//Set minimum cost to infinite
minCost = FLT_MAX;
//For every possible axis,
for(unsigned i = 0; i < NumAxes; ++i)
{
//Generate the event list for this axis
curAxis = (SplitAxis)i;
generateEventList(triList, parentBox);
//All of the triangles are to our right.
//These will remain through iterations on positions
Nl = 0;
Nr = triList.size();
Nc = 0;
//For every position
for(unsigned j = 0; j < eventList.size(); )
{
float curPos = eventList[j].eventPos;
Vs = Ve = Vc = 0;
//Count the triangles starting, ending, and coplanar with this position
//This will advance j to the next event position
countTrisOfEvent(Vs, Ve, Vc, j, curPos);
Nc = Vc;
Nr -= Ve + Vc;
//The last index is the positions we care about.
calcCostOfPlane(Nl, Nr, Nc, parentBox, curPos);
Nl += Vs + Vc;
//Update the lowest possible plane
if(curCost < minCost)
{
minCost = curCost;
//Save what axis and position we're going to cut at so far...
splitPos = curPos;
splitAxis = curAxis;
}
}
}
}
示例12: UpdateIndices
void MeshMender::UpdateIndices(const size_t oldIndex , const size_t newIndex , TriangleList& curGroup)
{
//make any triangle that used the oldIndex use the newIndex instead
for( size_t t = 0; t < curGroup.size(); ++t )
{
TriID tID = curGroup[ t ];
for(size_t indx = 0 ; indx < 3 ; ++indx)
{
if(m_Triangles[tID].indices[indx] == oldIndex)
{
m_Triangles[tID].indices[indx] = newIndex;
}
}
}
}
示例13: triangulate
void Triangulator::triangulate(const Contour &contour, TriangleList &triangles, int index_offset) {
Path path;
build_path(contour, path, index_offset);
triangles.reserve(triangles.size() + 3*(path.size() - 2));
split_path(&path.front(), triangles);
}
示例14: getCommonTriangles
TriangleList getCommonTriangles(QPointF *points, quint32 size, quint32 layers,
Vertex v1, Vertex v2, QPointF *centerPtr) {
TriangleList result;
if (v1.layer > v2.layer)
qSwap(v1, v2);
if (!v2.layer)
return result;
if (v1.layer == 0 && v2.layer == 1) {
result.append(TRIANGLE(0, v2.sector, 0));
result.append(TRIANGLE(0, (v2.sector + size - 1) % size, 0));
} else if (v1.sector == v2.sector) {
if (v1.layer == v2.layer) {
if (v2.index == v1.index + 1) {
if (v1.layer < layers)
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2 + 1));
result.append(TRIANGLE(v1.layer - 1, v1.sector, v1.index * 2));
} else if (v2.index == v1.index - 1) {
if (v1.layer < layers)
result.append(TRIANGLE(v1.layer, v1.sector, v2.index * 2 + 1));
result.append(TRIANGLE(v1.layer - 1, v1.sector, v2.index * 2));
}
}
else if (v2.layer == v1.layer + 1) {
if (v2.index == v1.index) {
if (v1.index)
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2 - 1));
else
result.append(TRIANGLE(v1.layer, (v1.sector + size - 1) % size, v1.layer * 2));
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2));
} else if (v2.index == v1.index + 1) {
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2));
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2 + 1));
}
}
} else if ((v2.sector == (v1.sector + 1) % size)
&& v1.index == v1.layer - 1 && v2.index == 0) {
if (v1.layer == v2.layer) {
result.append(TRIANGLE(v1.layer - 1, v1.sector, v1.index * 2));
if (v1.layer < layers)
result.append(TRIANGLE(v1.layer, v1.sector, v1.index * 2 + 1));
} else if (v1.layer == v2.layer + 1) {
result.append(TRIANGLE(v2.layer, v1.sector, v1.index * 2 - 1));
result.append(TRIANGLE(v2.layer, v1.sector, v1.index * 2));
}
} else if ((v1.sector == (v2.sector + 1) % size)
&& v2.index == v2.layer - 1 && v1.index == 0) {
if (v1.layer == v2.layer) {
result.append(TRIANGLE(v1.layer - 1, v2.sector, v2.index * 2));
if (v1.layer < layers)
result.append(TRIANGLE(v1.layer, v2.sector, v2.index * 2 + 1));
} else if (v1.layer == v2.layer - 1) {
result.append(TRIANGLE(v1.layer, v2.sector, v2.index * 2 - 1));
result.append(TRIANGLE(v1.layer, v2.sector, v2.index * 2));
}
}
return result;
}
示例15: findOptimalSplitPositon
void KDTree::Subdivide(KDTreeNode &node,TriangleList *triangles,aabb& box,int depth)
{
if(!triangles)return ;
int count = triangles->GetCount();
if( count < minTrianglesPerleafNode ||(depth>=20&&count<=maxTrianglesPerleafNode))
{
node.SetTriangleList(triangles);
node.Type = LEFT;
node.box = box;
return ;
}
aabb frontBox,backBox;
real splitPosition;
bool foundOptimalSplit = findOptimalSplitPositon(triangles,box,depth,splitPosition,frontBox, backBox);
if(foundOptimalSplit == true)
{
node.Type = PATITION;
node.SetAxis(depth%Dimension);
node.SetSplitPosition(splitPosition);
node.box = box;
TriangleList *frontTriangles = new TriangleList();
TriangleList *backTriangles = new TriangleList();
for( int i=0; i < count; i++)
{
//Determine on which side of the split each
//triangle belongs.
TriangleNode * triangle= triangles->GetHead();
triangles->DeleteHead();
int position = partitionTriangle(triangle,depth,splitPosition);
triangle->next = NULL;
switch(position)
{
case kdBefore:
frontTriangles->append(triangle);
break;
case kdAfter:
backTriangles->append(triangle);
break;
case kdIntersection:
//frontTriangles->append(triangle);
backTriangles->append(triangle);
break;
}
}
node.m_lchild = new KDTreeNode();
node.m_rchild = new KDTreeNode();
Subdivide(*node.m_lchild,frontTriangles,frontBox,depth+1);
Subdivide(*node.m_rchild,backTriangles,backBox,depth+1);
}else
{
node.SetTriangleList(triangles);
node.Type = LEFT;
node.box = box;
}
}