本文整理汇总了C++中Quad::Set4Points方法的典型用法代码示例。如果您正苦于以下问题:C++ Quad::Set4Points方法的具体用法?C++ Quad::Set4Points怎么用?C++ Quad::Set4Points使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quad
的用法示例。
在下文中一共展示了Quad::Set4Points方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFrom
bool PhysicsMesh::LoadFrom(Mesh * mesh)
{
// Clear old
triangles.ClearAndDelete();
quads.ClearAndDelete();
name = mesh->name;
source = mesh->source;
aabb = *mesh->aabb;
for (int i = 0; i < mesh->numFaces; ++i)
{
// Just copy shit from it
MeshFace * faces = &mesh->faces[i];
assert((faces->numVertices <= 4 || faces->numVertices >= 3) && "Bad vertices count in faces");
int vi0 = faces->vertices[0],
vi1 = faces->vertices[1],
vi2 = faces->vertices[2];
assert(vi0 < mesh->vertices.Size() &&
vi0 >= 0);
Vector3f p1 = mesh->vertices[vi0],
p2 = mesh->vertices[vi1],
p3 = mesh->vertices[vi2];
if (faces->numVertices == 4){
Vector3f p4 = mesh->vertices[faces->vertices[3]];
Quad * quad = new Quad();
quad->Set4Points(p1, p2, p3, p4);
quads.Add(quad);
}
else if (faces->numVertices == 3){
Triangle * tri = new Triangle();
tri->Set3Points(p1, p2, p3);
triangles.Add(tri);
}
}
if (quads.Size() == 0 && triangles.Size() == 0)
assert(false && "Unable to load physicsmesh from mesh source!");
else
std::cout<<"\nCreated physics mesh for \""<<source<<"\": ";
if (triangles.Size())
std::cout<<"\n- "<<triangles.Size()<<" triangles";
if (quads.Size())
std::cout<<"\n- "<<quads.Size()<<" quads";
// Re-generate it.
if (useCollisionShapeOctrees)
GenerateCollisionShapeOctree();
return true;
}
示例2: Process
int CVFindQuads::Process(CVPipeline * pipe)
{
pipe->quads.Clear();
good = false;
/// Check for ... in pipeline
if (pipe->corners.size() == 0 &&
pipe->lines.Size() == 0)
{
errorString = "No corners or lines in pipeline.";
return -1;
}
float minimumWidthSquared = minimumWidth->GetInt() * minimumWidth->GetInt();
// Line-style!
if (pipe->lines.Size())
{
int linesAtStart = pipe->lines.Size();
std::cout<<"\nLines: "<<linesAtStart;
/// Then try to locate at least 2 lines that are parallel first?
// Approximate, assume 2 horizontal lines, and pick those two which are extremes (highest and lowest).
List<Line> singleLines;
for (int i = 0; i < pipe->lines.Size(); ++i)
{
Line line = pipe->lines[i];
Line line2;
bool foundPair = false;
// Compare with list of lines.
for (int j = 0; j < singleLines.Size(); ++j)
{
line2 = singleLines[j];
// Any suitable?
// First check length.
if (AbsoluteValue(line.Length() - line2.Length()) > maxLengthDiff->GetFloat())
continue;
// Ensure both the start and end points are pretty parallel
if (AbsoluteValue(line.start.x - line2.start.x) > maxCornerXDiff->GetFloat())
continue;
if (AbsoluteValue(line.stop.x - line2.stop.x) > maxCornerXDiff->GetFloat())
continue;
foundPair = true;
break;
}
if (foundPair)
{
// Limit the range in X for both lines so that they work "together" (overlapping)
#define Minimum(a,b) ( (a < b) ? a : b)
#define Maximum(a,b) ( (a > b) ? a : b)
Line min, max;
if (line.start.y < line2.start.y){
min = line;
max = line2;
}
else {
min = line2;
max = line;
}
min.stop.x = max.stop.x = Minimum(min.stop.x, max.stop.x);
min.start.x = max.start.x = Maximum(min.start.x, max.start.x);
// Create rectangle using these two lines! o-o
Quad quad;
quad.Set4Points(min.start, min.stop, max.stop, max.start);
pipe->quads.Add(quad);
good = true;
}
// If not, add this line to the list.
else
singleLines.Add(line);
}
}
// Use corners if we have any.
if (pipe->corners.size()){
// Constraint for now...
if (pipe->corners.size() != 4){
errorString = "Skipping. Simple algorithm requires exactly 4 corners.";
return -1;
}
// Look through all corners. Find the top 2 and bottom 2.
List<cv::Point2f> sortedList, unsortedList;
for (int i = 0; i < pipe->corners.size(); ++i)
unsortedList.Add(pipe->corners[i]);
/// Sort by Y-position.
while (unsortedList.Size())
{
cv::Point2f max = unsortedList[0];
int maxIndex = 0;
for (int i = 1; i < unsortedList.Size(); ++i)
{
cv::Point2f point = pipe->corners[i];
if (point.y > max.y){
max = point;
maxIndex = i;
}
}
// Add the max to the sortedList and remove it from the list to be sorted.
sortedList.Add(max);
//.........这里部分代码省略.........