Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tokarevart committed Jun 22, 2019
1 parent c725291 commit 8511790
Show file tree
Hide file tree
Showing 87 changed files with 1,820 additions and 279 deletions.
Binary file added Release/edge.obj
Binary file not shown.
Binary file added Release/example.obj
Binary file not shown.
Binary file added Release/face.obj
Binary file not shown.
Binary file added Release/logger.obj
Binary file not shown.
Binary file added Release/polyhedral-set.obj
Binary file not shown.
Binary file added Release/polyhedron-front-edge.obj
Binary file not shown.
Binary file added Release/polyhedron-front-face.obj
Binary file not shown.
Binary file added Release/polyhedron.obj
Binary file not shown.
Binary file added Release/polymesh.obj
Binary file not shown.
Binary file added Release/polymgen.exe
Binary file not shown.
Binary file added Release/polymgen.iobj
Binary file not shown.
Binary file added Release/polymgen.ipdb
Binary file not shown.
26 changes: 26 additions & 0 deletions Release/polymgen.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
 example.cpp
edge.cpp
face.cpp
polyhedron-front-edge.cpp
polyhedron-front-face.cpp
polyhedral-set.cpp
polyhedron.cpp
relations.cpp
surface-front-edge.cpp
surface-front-vert.cpp
surface-edge.cpp
F:\Programming\Programs\VsPrograms\polymgen\src\core\polyhedron.cpp(1730,22): warning C4244: аргумент: преобразование "size_t" в "real_t", возможна потеря данных
surface-face.cpp
F:\Programming\Programs\VsPrograms\polymgen\src\core\surface\surface-edge.cpp(34,69): warning C4244: аргумент: преобразование "size_t" в "real_t", возможна потеря данных
tetr.cpp
polymesh.cpp
polyshell.cpp
spatial-algs.cpp
polysgen.cpp
F:\Programming\Programs\VsPrograms\polymgen\src\core\surface\surface-face.cpp(646,22): warning C4244: аргумент: преобразование "int" в "real_t", возможна потеря данных
Создание кода
372 of 2294 functions (16.2%) were compiled, the rest were copied from previous compilation.
140 functions were new in current compilation
17 functions had inline decision re-evaluated but remain unchanged
Создание кода завершено
polymgen.vcxproj -> F:\Programming\Programs\VsPrograms\polymgen\Release\polymgen.exe
Binary file added Release/polymgen.pdb
Binary file not shown.
Binary file added Release/polymgen.tlog/CL.command.1.tlog
Binary file not shown.
Binary file added Release/polymgen.tlog/CL.read.1.tlog
Binary file not shown.
Binary file added Release/polymgen.tlog/CL.write.1.tlog
Binary file not shown.
Binary file added Release/polymgen.tlog/link.command.1.tlog
Binary file not shown.
Binary file added Release/polymgen.tlog/link.delete.1.tlog
Binary file not shown.
Binary file added Release/polymgen.tlog/link.read.1.tlog
Binary file not shown.
Binary file added Release/polymgen.tlog/link.write.1.tlog
Binary file not shown.
2 changes: 2 additions & 0 deletions Release/polymgen.tlog/polymgen.lastbuildstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
Release|Win32|F:\Programming\Programs\VsPrograms\polymgen\|
Binary file added Release/polymgen.tlog/polymgen.write.1u.tlog
Binary file not shown.
Binary file added Release/polysgen.obj
Binary file not shown.
Binary file added Release/polyshell.obj
Binary file not shown.
Binary file added Release/relations.obj
Binary file not shown.
Binary file added Release/spatial-algs.obj
Binary file not shown.
Binary file added Release/surface-edge.obj
Binary file not shown.
Binary file added Release/surface-face.obj
Binary file not shown.
Binary file added Release/surface-front-edge.obj
Binary file not shown.
Binary file added Release/surface-front-vert.obj
Binary file not shown.
Binary file added Release/surface.obj
Binary file not shown.
Binary file added Release/tetr.obj
Binary file not shown.
Binary file added Release/vc142.pdb
Binary file not shown.
36 changes: 19 additions & 17 deletions example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int main()
{
std::cout << rabbit() << std::endl;

real_t preferredLength = static_cast<real_t>(0.32);
real_t preferredLength = static_cast<real_t>(0.5);

std::cout << "Generating PolyShell...";
std::size_t n = 4;
Expand All @@ -45,26 +45,28 @@ int main()
std::cout << "Generating mesh...";
polyhset.tetrahedralize(preferredLength);
std::cout << std::string(12, ' ') + "done." << std::endl;
std::cout << std::endl << polyhset.generateLogFileName();
//namespace fs = std::filesystem;
//std::cout << "Outputting data to file...";

//fs::create_directories(fs::current_path() / "out" / "meshes");
//fs::current_path(fs::current_path() / "out" / "meshes");
//std::cout << std::endl << polyhset.generateLogFileName();

//polyhset.output(pmg::FileType::LsDynaKeyword);
//polyhset.output(pmg::FileType::WavefrontObj);
//std::cout << std::string(4, ' ') + "done." << std::endl << std::endl;
namespace fs = std::filesystem;
std::cout << "Outputting data to file...";

//fs::current_path(fs::current_path().parent_path());
//fs::create_directory(fs::current_path() / "logs");
//fs::current_path(fs::current_path() / "logs");
fs::create_directories(fs::current_path() / "out" / "meshes");
fs::current_path(fs::current_path() / "out" / "meshes");

//std::ofstream log_file(polyhset.generateLogFileName());
//polyhset.log().write(log_file);
//std::cout << "Log:" << std::endl;
//polyhset.log().write(std::cout);
//log_file.close();
polyhset.output(pmg::FileType::LsDynaKeyword);
polyhset.output(pmg::FileType::WavefrontObj);
std::cout << std::string(4, ' ') + "done." << std::endl << std::endl;

fs::current_path(fs::current_path().parent_path());
fs::create_directory(fs::current_path() / "logs");
fs::current_path(fs::current_path() / "logs");

std::ofstream log_file(polyhset.generateLogFileName());
polyhset.log().write(log_file);
std::cout << "Log:" << std::endl;
polyhset.log().write(std::cout);
log_file.close();

return 0;
}
7 changes: 0 additions & 7 deletions later/mesh/mesh-algs.h

This file was deleted.

29 changes: 29 additions & 0 deletions later/mesher/algs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once
#include "../polyspt/simplex.h"


namespace pmg {

template <std::size_t Dim, typename Real>
Real quality(const spt::simplex_v<3, Dim, Real>* simp)
{
std::array<Real, 4> sqr_prods =
{
static_cast<Real>(1.0),
static_cast<Real>(1.0),
static_cast<Real>(1.0),
static_cast<Real>(1.0)
};
for (std::size_t i = 0; i < 4; i++)
for (std::size_t j = 0; j < 4; j++)
if (j != i)
sqr_prods[i] *= (simp->vertices[j]->pos - simp->vertices[i]->pos).sqr_magnitude();

Real max_sqr_prod = std::max({ sqr_prods[0], sqr_prods[1], sqr_prods[2], sqr_prods[3] });

constexpr auto CONST_12_SQRT2 = static_cast<Real>(8.4852813742385702928101323452582);

return CONST_12_SQRT2 * simp->volume() / std::sqrt(max_sqr_prod);
}

} // namespace pmg
40 changes: 21 additions & 19 deletions later/polyspt/algs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ bool spt::does_ray_intersect_triangle(
}


vec<3> spt::lines_closest_point(const vec<3>& line0_p0, const vec<3>& line0_p1, const vec<3>& line1_p0, const vec<3>& line1_p1)
vec<3> spt::lines_closest_point(
const vec<3>& line0_p0, const vec<3>& line0_p1, const vec<3>& line1_p0, const vec<3>& line1_p1)
{
vec<3> u = line0_p1 - line0_p0;
vec<3> v = line1_p1 - line1_p0;
Expand Down Expand Up @@ -435,7 +436,7 @@ vec<3>::real_type spt::distance_point_to_segment(const vec<3>& point, const vec<
{
return (proj - point).magnitude();
}
else if (vec<3>::real_type sqr_magns[2] { (segm_p0 - point).sqrMagnitude(), (segm_p1 - point).sqrMagnitude() };
else if (vec<3>::real_type sqr_magns[2] { (segm_p0 - point).sqr_magnitude(), (segm_p1 - point).sqr_magnitude() };
sqr_magns[0] < sqr_magns[1])
{
return std::sqrt(sqr_magns[0]);
Expand All @@ -456,26 +457,27 @@ vec<3>::real_type spt::distance_point_to_triangle_on_plane(
closest_points[2] = closest_segment_point_to_point(point, trngl_p2, trngl_p0);

std::array<vec<3>::real_type, 3> sqrs;
sqrs[0] = (closest_points[0] - point).sqrMagnitude();
sqrs[1] = (closest_points[1] - point).sqrMagnitude();
sqrs[2] = (closest_points[2] - point).sqrMagnitude();
sqrs[0] = (closest_points[0] - point).sqr_magnitude();
sqrs[1] = (closest_points[1] - point).sqr_magnitude();
sqrs[2] = (closest_points[2] - point).sqr_magnitude();

return std::min({ sqrs[0], sqrs[1], sqrs[2] });
}


bool spt::does_triangle_intersect_sphere(const vec<3>& trngl_p0, const vec<3>& trngl_p1, const vec<3>& trngl_p2,
const vec<3>& center, vec<3>::real_type radius)
bool spt::does_triangle_intersect_sphere(
const vec<3>& trngl_p0, const vec<3>& trngl_p1, const vec<3>& trngl_p2,
const vec<3>& center, vec<3>::real_type radius)
{
vec<3> proj = project(center, trngl_p0, trngl_p1, trngl_p2);
if ((proj - center).sqrMagnitude() > radius * radius)
if ((proj - center).sqr_magnitude() > radius * radius)
return false;

if (is_point_on_triangle(proj, trngl_p0, trngl_p1, trngl_p2, max_sqrs_sum(trngl_p0, trngl_p1, trngl_p2)))
return true;

vec<3> closest = closest_triangle_point_to_point_on_plane(proj, trngl_p0, trngl_p1, trngl_p2);
return (closest - center).sqrMagnitude() <= radius * radius;
return (closest - center).sqr_magnitude() <= radius * radius;
}


Expand All @@ -487,7 +489,7 @@ vec<3> spt::closest_segment_point_to_point(const vec<3>& point, const vec<3>& se
{
return proj;
}
else if (vec<3>::real_type sqr_magns[2] { (segm_p0 - point).sqrMagnitude(), (segm_p1 - point).sqrMagnitude() };
else if (vec<3>::real_type sqr_magns[2] { (segm_p0 - point).sqr_magnitude(), (segm_p1 - point).sqr_magnitude() };
sqr_magns[0] < sqr_magns[1])
{
return segm_p0;
Expand All @@ -502,9 +504,9 @@ vec<3> spt::closest_segment_point_to_point(const vec<3>& point, const vec<3>& se
vec<3>::real_type spt::max_sqrs_sum(const vec<3>& trngl_p0, const vec<3>& trngl_p1, const vec<3>& trngl_p2)
{
std::array<vec<3>::real_type, 3> sqrs;
sqrs[0] = (trngl_p1 - trngl_p0).sqrMagnitude();
sqrs[1] = (trngl_p2 - trngl_p1).sqrMagnitude();
sqrs[2] = (trngl_p0 - trngl_p2).sqrMagnitude();
sqrs[0] = (trngl_p1 - trngl_p0).sqr_magnitude();
sqrs[1] = (trngl_p2 - trngl_p1).sqr_magnitude();
sqrs[2] = (trngl_p0 - trngl_p2).sqr_magnitude();

std::size_t max_inds[2];
if (sqrs[0] < sqrs[1])
Expand All @@ -531,9 +533,9 @@ vec<3>::real_type spt::max_sqrs_sum(const vec<3>& trngl_p0, const vec<3>& trngl_
vec<3>::real_type spt::sqrs_sum(const vec<3>& point, const vec<3>& trngl_p0, const vec<3>& trngl_p1, const vec<3>& trngl_p2)
{
std::array<vec<3>::real_type, 3> sqrs;
sqrs[0] = (trngl_p0 - point).sqrMagnitude();
sqrs[1] = (trngl_p1 - point).sqrMagnitude();
sqrs[2] = (trngl_p2 - point).sqrMagnitude();
sqrs[0] = (trngl_p0 - point).sqr_magnitude();
sqrs[1] = (trngl_p1 - point).sqr_magnitude();
sqrs[2] = (trngl_p2 - point).sqr_magnitude();
return sqrs[0] + sqrs[1] + sqrs[2];
}

Expand All @@ -547,9 +549,9 @@ vec<3> spt::closest_triangle_point_to_point_on_plane(
closest_points[2] = closest_segment_point_to_point(point, trngl_p2, trngl_p0);

std::array<vec<3>::real_type, 3> sqrs;
sqrs[0] = (closest_points[0] - point).sqrMagnitude();
sqrs[1] = (closest_points[1] - point).sqrMagnitude();
sqrs[2] = (closest_points[2] - point).sqrMagnitude();
sqrs[0] = (closest_points[0] - point).sqr_magnitude();
sqrs[1] = (closest_points[1] - point).sqr_magnitude();
sqrs[2] = (closest_points[2] - point).sqr_magnitude();

std::size_t min_i;
if (sqrs[0] < sqrs[1])
Expand Down
5 changes: 3 additions & 2 deletions later/polyspt/dion.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ struct polytope<1, Dim, Real>
}
polytope(const std::array<facet_type*, 2>& vertices)
: vertices(vertices) {}
polytope(const facet_type* v0, const facet_type* v1)
: vertices({ v0, v1 }) {}
template <typename... Vertices>
polytope(Vertices... verts)
: vertices{ verts... } {}
};

} // namespace spt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once


namespace pmg {
namespace spt {

enum class elem_shape
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once
#include <vector>
#include "indexed_mesh-base.h"
#include "../polyspt/polyhedron.h"
#include "polyhedron.h"


namespace pmg {
namespace spt {

template <std::size_t Dim, typename Real>
struct indexed_mesh<spt::dion<Dim, Real>, pmg::elem_shape::polytope>
struct indexed_mesh<spt::dion<Dim, Real>, spt::elem_shape::polytope>
{
using polytope_type = spt::dion<Dim, Real>;
using real_type = Real;
Expand All @@ -20,7 +20,7 @@ struct indexed_mesh<spt::dion<Dim, Real>, pmg::elem_shape::polytope>
};

template <std::size_t Dim, typename Real>
struct indexed_mesh<spt::polygon<Dim, Real>, pmg::elem_shape::polytope>
struct indexed_mesh<spt::polygon<Dim, Real>, spt::elem_shape::polytope>
{
using polytope_type = spt::polygon<Dim, Real>;
using real_type = Real;
Expand All @@ -35,7 +35,7 @@ struct indexed_mesh<spt::polygon<Dim, Real>, pmg::elem_shape::polytope>
};

template <std::size_t Dim, typename Real>
struct indexed_mesh<spt::polyhedron<Dim, Real>, pmg::elem_shape::polytope>
struct indexed_mesh<spt::polyhedron<Dim, Real>, spt::elem_shape::polytope>
{
using polytope_type = spt::polyhedron<Dim, Real>;
using real_type = Real;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include "indexed_mesh-base.h"


namespace pmg {
namespace spt {

template <typename Polytope>
struct indexed_mesh<Polytope, pmg::elem_shape::simplex>
struct indexed_mesh<Polytope, spt::elem_shape::simplex>
{
using polytope_type = Polytope;
using real_type = typename polytope_type::real_type;
Expand All @@ -19,7 +19,7 @@ struct indexed_mesh<Polytope, pmg::elem_shape::simplex>
};

template <typename Polytope>
struct indexed_mesh<spt::aggregate<Polytope>, pmg::elem_shape::simplex>
struct indexed_mesh<spt::aggregate<Polytope>, spt::elem_shape::simplex>
{
using polytope_type = Polytope;
using real_type = typename polytope_type::real_type;
Expand Down
File renamed without changes.
18 changes: 16 additions & 2 deletions later/mesh/mesh-base.h → later/polyspt/mesh-base.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once
#include "../polyspt/simplex.h"
#include "simplex.h"
#include <vector>

namespace pmg {
namespace spt {

enum class elem_shape
{
Expand All @@ -13,6 +14,9 @@ enum class elem_shape
template <typename Polytope, elem_shape ElemShape>
struct mesh;

template <typename Polytope, elem_shape ElemShape>
struct mesh_v;

template <typename Polytope, elem_shape ElemShape>
struct mesh<spt::aggregate<Polytope>, ElemShape>
{
Expand All @@ -23,4 +27,14 @@ struct mesh<spt::aggregate<Polytope>, ElemShape>
std::vector<submesh_type*> meshes;
};

template <typename Polytope, elem_shape ElemShape>
struct mesh_v<spt::aggregate<Polytope>, ElemShape>
{
using polytope_type = Polytope;
using real_type = typename polytope_type::real_type;
using submesh_type = mesh_v<polytope_type, ElemShape>;

std::vector<submesh_type*> meshes;
};

} // namespace pmg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "mesh-base.h"

namespace pmg {
namespace spt {

template <typename Polytope>
struct mesh<Polytope, elem_shape::polytope>
Expand Down
34 changes: 34 additions & 0 deletions later/polyspt/mesh-simplex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once
#include "mesh-base.h"

namespace spt {

template <typename Polytope>
struct mesh<Polytope, elem_shape::simplex>
{
using polytope_type = Polytope;
using real_type = typename polytope_type::real_type;
using vertex_type = spt::vertex<polytope_type::dim, real_type>;
// ...
using facet_type = spt::simplex<polytope_type::n - 1, polytope_type::dim, real_type>;
using elem_type = spt::simplex<polytope_type::n, polytope_type::dim, real_type>;

std::vector<vertex_type*> vertices;
// ...
std::vector<facet_type*> facets;
std::vector<elem_type*> elements;
};

template <typename Polytope>
struct mesh_v<Polytope, elem_shape::simplex>
{
using polytope_type = Polytope;
using real_type = typename polytope_type::real_type;
using vertex_type = spt::vertex<polytope_type::dim, real_type>;
using elem_type = spt::simplex_v<polytope_type::n, polytope_type::dim, real_type>;

std::vector<vertex_type*> vertices;
std::vector<elem_type*> elements;
};

} // namespace pmg
File renamed without changes.
9 changes: 0 additions & 9 deletions later/polyspt/polychoron.h

This file was deleted.

Loading

0 comments on commit 8511790

Please sign in to comment.