本文整理汇总了C++中MatrixFr::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixFr::resize方法的具体用法?C++ MatrixFr::resize怎么用?C++ MatrixFr::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixFr
的用法示例。
在下文中一共展示了MatrixFr::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_box
void create_box(const VectorF& bbox_min, const VectorF& bbox_max,
MatrixFr& box_vertices, MatrixIr& box_faces) {
box_vertices.resize(8, 3);
box_faces.resize(12, 3);
box_vertices << bbox_min[0], bbox_min[1], bbox_min[2],
bbox_max[0], bbox_min[1], bbox_min[2],
bbox_max[0], bbox_max[1], bbox_min[2],
bbox_min[0], bbox_max[1], bbox_min[2],
bbox_min[0], bbox_min[1], bbox_max[2],
bbox_max[0], bbox_min[1], bbox_max[2],
bbox_max[0], bbox_max[1], bbox_max[2],
bbox_min[0], bbox_max[1], bbox_max[2];
box_faces << 1, 2, 5,
5, 2, 6,
3, 4, 7,
3, 0, 4,
2, 3, 6,
3, 7, 6,
0, 1, 5,
0, 5, 4,
4, 5, 6,
4, 6, 7,
0, 3, 2,
0, 2, 1;
}
示例2: extract_data
void extract_data(CarveMeshPtr mesh, MatrixFr& vertices, MatrixIr& faces) {
typedef CarveMesh::vertex_t CarveVertex;
const size_t num_vertices = mesh->vertex_storage.size();
vertices.resize(num_vertices, 3);
for (size_t i=0; i<num_vertices; i++) {
const auto& v = mesh->vertex_storage[i];
vertices(i,0) = v.v.x;
vertices(i,1) = v.v.y;
vertices(i,2) = v.v.z;
}
const size_t num_faces = mesh->faceEnd() - mesh->faceBegin();
faces.resize(num_faces, 3);
for (auto itr=mesh->faceBegin(); itr != mesh->faceEnd(); itr++) {
std::vector<CarveVertex* > vts;
(*itr)->getVertices(vts);
assert(vts.size() == 3);
// WARNING:
// Here is my guess on how to extract vertex index.
// Carve's documentation is not clear on how to do this.
const size_t fid = itr - mesh->faceBegin();
faces(fid, 0) = vts[0] - &mesh->vertex_storage[0];
faces(fid, 1) = vts[1] - &mesh->vertex_storage[0];
faces(fid, 2) = vts[2] - &mesh->vertex_storage[0];
}
}
示例3: extract_mesh
void extract_mesh(const C3t3& c3t3,
MatrixFr& vertices, MatrixIr& faces, MatrixIr& voxels) {
const Tr& tr = c3t3.triangulation();
size_t num_vertices = tr.number_of_vertices();
size_t num_faces = c3t3.number_of_facets_in_complex();
size_t num_voxels = c3t3.number_of_cells_in_complex();
vertices.resize(num_vertices, 3);
faces.resize(num_faces, 3);
voxels.resize(num_voxels, 4);
std::map<Tr::Vertex_handle, int> V;
size_t inum = 0;
for(auto vit = tr.finite_vertices_begin();
vit != tr.finite_vertices_end(); ++vit) {
V[vit] = inum;
const auto& p = vit->point();
vertices.row(inum) = Vector3F(p.x(), p.y(), p.z()).transpose();
assert(inum < num_vertices);
inum++;
}
assert(inum == num_vertices);
size_t face_count = 0;
for(auto fit = c3t3.facets_in_complex_begin();
fit != c3t3.facets_in_complex_end(); ++fit) {
assert(face_count < num_faces);
for (int i=0; i<3; i++) {
if (i != fit->second) {
const auto& vh = (*fit).first->vertex(i);
assert(V.find(vh) != V.end());
const int vid = V[vh];
faces(face_count, i) = vid;
}
}
face_count++;
}
assert(face_count == num_faces);
size_t voxel_count = 0;
for(auto cit = c3t3.cells_in_complex_begin() ;
cit != c3t3.cells_in_complex_end(); ++cit ) {
assert(voxel_count < num_voxels);
for (int i=0; i<4; i++) {
assert(V.find(cit->vertex(i)) != V.end());
const size_t vid = V[cit->vertex(i)];
voxels(voxel_count, i) = vid;
}
voxel_count++;
}
assert(voxel_count == num_voxels);
}