本文整理汇总了C++中SimpleMesh::size方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleMesh::size方法的具体用法?C++ SimpleMesh::size怎么用?C++ SimpleMesh::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleMesh
的用法示例。
在下文中一共展示了SimpleMesh::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: segmentMeshWitAABox
bool ManualSegmentationTools::segmentMeshWitAABox(GenericIndexedMesh* origMesh,
GenericIndexedCloudPersist* origVertices,
MeshCutterParams& ioParams,
GenericProgressCallback* progressCb/*=0*/)
{
if (!origMesh
|| !origVertices
|| origMesh->size() == 0
|| origVertices->size() < 3
|| ioParams.bbMin.x >= ioParams.bbMax.x
|| ioParams.bbMin.y >= ioParams.bbMax.y
|| ioParams.bbMin.z >= ioParams.bbMax.z)
{
//invalid input parameters
return false;
}
if (origMesh->size() > c_realIndexMask)
{
//too many triangles!
return false;
}
const double& epsilon = ioParams.epsilon;
const CCVector3d& bbMin = ioParams.bbMin;
const CCVector3d& bbMax = ioParams.bbMax;
//indexes of original triangle that are not modified bt copied "as is"
std::vector<unsigned> preservedTrianglesInside1; //insde (1)
std::vector<unsigned> preservedTrianglesInside2; //insde (2)
std::vector<unsigned> preservedTrianglesOutside; //outside
//inside meshes (swapped for each dimension)
ChunkedPointCloud* insideVertices1 = new ChunkedPointCloud;
SimpleMesh* insideMesh1 = new SimpleMesh(insideVertices1, true);
ChunkedPointCloud* insideVertices2 = new ChunkedPointCloud;
SimpleMesh* insideMesh2 = new SimpleMesh(insideVertices2, true);
//outside mesh (output)
ChunkedPointCloud* outsideVertices = 0;
SimpleMesh* outsideMesh = 0;
if (ioParams.generateOutsideMesh)
{
outsideVertices = new ChunkedPointCloud;
outsideMesh = new SimpleMesh(outsideVertices, true);
}
//pointers on input and output structures (will change for each dimension)
std::vector<unsigned>* preservedTrianglesInside = &preservedTrianglesInside1;
std::vector<unsigned>* formerPreservedTriangles = &preservedTrianglesInside2;
ChunkedPointCloud* insideVertices = insideVertices1;
SimpleMesh* insideMesh = insideMesh1;
GenericIndexedMesh* sourceMesh = origMesh;
GenericIndexedCloudPersist* sourceVertices = origVertices;
CCVector3d boxCenter = (ioParams.bbMin + ioParams.bbMax) / 2;
CCVector3d boxHalfSize = (ioParams.bbMax - ioParams.bbMin) / 2;
bool error = false;
//for each triangle
try
{
//for each plane
for (unsigned d = 0; d < 6; ++d)
{
//Extract the 'plane' information corresponding to the input box faces
//-X,+X,-Y,+Y,-Z,+Z
unsigned char Z = static_cast<unsigned char>(d / 2);
double planeCoord = ((d & 1) ? bbMax : bbMin).u[Z];
bool keepBelow = ((d & 1) ? true : false);
assert(preservedTrianglesInside && formerPreservedTriangles);
assert(insideVertices && insideMesh);
assert(sourceVertices && sourceMesh);
s_edgePoint.clear();
std::vector<unsigned> origTriIndexesMapInsideBackup;
if (ioParams.trackOrigIndexes)
{
origTriIndexesMapInsideBackup = ioParams.origTriIndexesMapInside;
ioParams.origTriIndexesMapInside.clear();
}
//look for original triangles
//(the first time they only come from the original mesh but afterwards
// they can come from the original mesh through the 'preserved' list
// or from the previous 'inside' mesh as we have to test those triangles
// against the new plane)
unsigned sourceTriCount = sourceMesh ? sourceMesh->size() : 0; //source: previous/original mesh
unsigned formerPreservedTriCount = static_cast<unsigned>(formerPreservedTriangles->size());
unsigned triCount = sourceTriCount + formerPreservedTriCount;
for (unsigned i = 0; i < triCount; ++i)
{
bool triangleIsOriginal = false;
unsigned souceTriIndex = 0;
const VerticesIndexes* tsi = 0;
if (i < sourceTriCount)
{
souceTriIndex = i;
//.........这里部分代码省略.........
示例2: segmentMesh
GenericIndexedMesh* ManualSegmentationTools::segmentMesh(GenericIndexedMesh* theMesh, ReferenceCloud* pointIndexes, bool pointsWillBeInside, GenericProgressCallback* progressCb, GenericIndexedCloud* destCloud, unsigned indexShift)
{
if (!theMesh || !pointIndexes || !pointIndexes->getAssociatedCloud())
return 0;
//by default we try a fast process (but with a higher memory consumption)
unsigned numberOfPoints = pointIndexes->getAssociatedCloud()->size();
unsigned numberOfIndexes = pointIndexes->size();
//we determine for each point if it is used in the output mesh or not
//(and we compute its new index by the way: 0 means that the point is not used, otherwise its index will be newPointIndexes-1)
std::vector<unsigned> newPointIndexes;
{
try
{
newPointIndexes.resize(numberOfPoints,0);
}
catch (const std::bad_alloc&)
{
return 0; //not enough memory
}
for (unsigned i=0; i<numberOfIndexes; ++i)
{
assert(pointIndexes->getPointGlobalIndex(i) < numberOfPoints);
newPointIndexes[pointIndexes->getPointGlobalIndex(i)] = i+1;
}
}
//negative array for the case where input points are "outside"
if (!pointsWillBeInside)
{
unsigned newIndex = 0;
for (unsigned i=0;i<numberOfPoints;++i)
newPointIndexes[i] = (newPointIndexes[i] == 0 ? ++newIndex : 0);
}
//create resulting mesh
SimpleMesh* newMesh = 0;
{
unsigned numberOfTriangles = theMesh->size();
//progress notification
NormalizedProgress* nprogress = 0;
if (progressCb)
{
progressCb->reset();
progressCb->setMethodTitle("Extract mesh");
char buffer[256];
sprintf(buffer,"New vertex number: %u",numberOfIndexes);
nprogress = new NormalizedProgress(progressCb,numberOfTriangles);
progressCb->setInfo(buffer);
progressCb->start();
}
newMesh = new SimpleMesh(destCloud ? destCloud : pointIndexes->getAssociatedCloud());
unsigned count = 0;
theMesh->placeIteratorAtBegining();
for (unsigned i=0; i<numberOfTriangles; ++i)
{
bool triangleIsOnTheRightSide = true;
const VerticesIndexes* tsi = theMesh->getNextTriangleVertIndexes(); //DGM: getNextTriangleVertIndexes is faster for mesh groups!
int newVertexIndexes[3];
//VERSION: WE KEEP THE TRIANGLE ONLY IF ITS 3 VERTICES ARE INSIDE
for (uchar j=0;j <3; ++j)
{
const unsigned& currentVertexFlag = newPointIndexes[tsi->i[j]];
//if the vertex is rejected, we discard this triangle
if (currentVertexFlag == 0)
{
triangleIsOnTheRightSide = false;
break;
}
newVertexIndexes[j] = currentVertexFlag-1;
}
//if we keep the triangle
if (triangleIsOnTheRightSide)
{
if (count == newMesh->size() && !newMesh->reserve(newMesh->size() + 1000)) //auto expand mesh size
{
//stop process
delete newMesh;
newMesh = 0;
break;
}
++count;
newMesh->addTriangle( indexShift + newVertexIndexes[0],
indexShift + newVertexIndexes[1],
indexShift + newVertexIndexes[2] );
}
if (nprogress && !nprogress->oneStep())
{
//cancel process
//.........这里部分代码省略.........