diff --git a/apps/sample/sample.pro b/apps/sample/sample.pro index ba728998..3b590577 100644 --- a/apps/sample/sample.pro +++ b/apps/sample/sample.pro @@ -8,6 +8,7 @@ SUBDIRS = trimesh_allocate \ trimesh_clustering \ trimesh_color \ trimesh_copy \ + trimesh_create \ trimesh_curvature \ trimesh_cylinder_clipping \ trimesh_disk_parametrization \ @@ -37,6 +38,7 @@ SUBDIRS = trimesh_allocate \ trimesh_split_vertex \ trimesh_texture \ trimesh_topology \ + trimesh_topological_cut \ trimesh_voronoi \ trimesh_voronoiatlas \ trimesh_voronoiclustering \ diff --git a/apps/sample/trimesh_create/trimesh_create.cpp b/apps/sample/trimesh_create/trimesh_create.cpp new file mode 100644 index 00000000..269e1d78 --- /dev/null +++ b/apps/sample/trimesh_create/trimesh_create.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +* VCGLib o o * +* Visual and Computer Graphics Library o o * +* _ O _ * +* Copyright(C) 2004-2016 \/)\/ * +* Visual Computing Lab /\/| * +* ISTI - Italian National Research Council | * +* \ * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +/*! \file trimesh_create.cpp +\ingroup code_sample + +\brief Some examples of building meshes out of nothing + +*/ +#include +#include + +// input output +#include + +class MyFace; +class MyVertex; + +struct MyUsedTypes : public vcg::UsedTypes< vcg::Use::AsVertexType, vcg::Use::AsFaceType>{}; + +class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::Color4b, vcg::vertex::BitFlags >{}; +class MyFace : public vcg::Face < MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f, vcg::face::FFAdj, vcg::face::BitFlags > {}; +class MyMesh : public vcg::tri::TriMesh< std::vector, std::vector > {}; + +using namespace std; +using namespace vcg; + +int main() +{ + MyMesh diskMesh; + + // Create a simple triangle mesh using just a vector of coords and a vector of indexes + vector coordVec; + vector indexVec; + coordVec.push_back(Point3f(0,0,0)); + for(int i=0;i<36;++i) { + float angleRad = float(i)*M_PI/18.0; + coordVec.push_back(Point3f(sin(angleRad),cos(angleRad),0)); + indexVec.push_back(Point3i(0,i+1,1+(i+1)%36)); + } + + tri::BuildMeshFromCoordVectorIndexVector(diskMesh,coordVec,indexVec); + tri::io::ExporterOFF::Save(diskMesh,"disc.off"); + + // Create the platonic solids + MyMesh platonicMesh; + tri::Tetrahedron(platonicMesh); + tri::io::ExporterOFF::Save(platonicMesh,"tetrahedron.off"); + tri::Octahedron(platonicMesh); + tri::io::ExporterOFF::Save(platonicMesh,"octahedron.off"); + tri::Hexahedron(platonicMesh); + tri::io::ExporterOFF::Save(platonicMesh,"hexahedron.off"); + tri::Dodecahedron(platonicMesh); + tri::io::ExporterOFF::Save(platonicMesh,"dodecahedron.off"); + tri::Icosahedron(platonicMesh); + tri::io::ExporterOFF::Save(platonicMesh,"icosahedron.off"); + + // Procedurally transform a mesh into a solid collection of triangular prisms + MyMesh facePrismMesh; + tri::BuildPrismFaceShell(platonicMesh, facePrismMesh, 0.1f, 0.1f); + tri::io::ExporterOFF::Save(facePrismMesh,"facePrism.off"); + + return 0; +} diff --git a/apps/sample/trimesh_create/trimesh_create.pro b/apps/sample/trimesh_create/trimesh_create.pro new file mode 100644 index 00000000..a2e83bff --- /dev/null +++ b/apps/sample/trimesh_create/trimesh_create.pro @@ -0,0 +1,3 @@ +include(../common.pri) +TARGET = trimesh_create +SOURCES += trimesh_create.cpp