15 #ifndef __IPSDKGEOMETRY_MESHSIMPLIFICATION_H__ 16 #define __IPSDKGEOMETRY_MESHSIMPLIFICATION_H__ 20 #pragma warning (push) 21 #pragma warning (disable : 4251) 23 #include <IPSDKGeometry/Entity/3d/BaseTypedGeometryEntity3d.h> 24 #include <IPSDKGeometry/Entity/3d/Mesh/Mesh3d.h> 25 #include <IPSDKGeometry/Entity/3d/Mesh/SymmetricMatrix.h> 49 typedef FaceData* FaceDataArray;
53 typedef VertexData* VertexDataArray;
75 x = a.x; y = a.y; z = a.z;
78 inline vec3f(
const double X,
const double Y,
const double Z)
85 return vec3f(x + a.x, y + a.y, z + a.z);
88 inline vec3f operator += (
const vec3f& a)
const 90 return vec3f(x + a.x, y + a.y, z + a.z);
95 return vec3f(x * a, y * a, z * a);
100 return vec3f(x * a.x, y * a.y, z * a.z);
103 inline vec3f v3()
const 105 return vec3f(x, y, z);
110 x = a.x; y = a.y; z = a.z;
return *
this;
115 x = a.x; y = a.y; z = a.z;
return *
this;
120 return vec3f(x / a.x, y / a.y, z / a.z);
123 inline vec3f operator - (
const vec3f& a)
const 125 return vec3f(x - a.x, y - a.y, z - a.z);
128 inline vec3f operator / (
const double a)
const 130 return vec3f(x / a, y / a, z / a);
133 inline double dot(
const vec3f& a)
const 135 return a.x * x + a.y * y + a.z * z;
140 x = a.y * b.z - a.z * b.y;
141 y = a.z * b.x - a.x * b.z;
142 z = a.x * b.y - a.y * b.x;
146 inline double angle(
const vec3f& v)
148 vec3f a = v, b = *
this;
149 double dot = v.x * x + v.y * y + v.z * z;
150 double len = a.length() * b.length();
151 if (len == 0)len = 0.00001f;
152 double input = dot / len;
153 if (input < -1) input = -1;
154 if (input > 1) input = 1;
155 return (
double)acos(input);
158 inline double angle2(
const vec3f& v,
const vec3f& w)
160 vec3f a = v, b = *
this;
161 double dot = a.x * b.x + a.y * b.y + a.z * b.z;
162 double len = a.length() * b.length();
163 if (len == 0)len = 1;
165 vec3f plane; plane.cross(b, w);
167 if (plane.x * a.x + plane.y * a.y + plane.z * a.z > 0)
168 return (
double)-acos(dot / len);
170 return (
double)acos(dot / len);
173 inline vec3f rot_x(
double a)
175 double yy = cos(a) * y + sin(a) * z;
176 double zz = cos(a) * z - sin(a) * y;
180 inline vec3f rot_y(
double a)
182 double xx = cos(-a) * x + sin(-a) * z;
183 double zz = cos(-a) * z - sin(-a) * x;
187 inline void clamp(
double min,
double max)
196 inline vec3f rot_z(
double a)
198 double yy = cos(a) * y + sin(a) * x;
199 double xx = cos(a) * x - sin(a) * y;
203 inline vec3f invert()
205 x = -x; y = -y; z = -z;
return *
this;
216 inline vec3f integer()
225 inline double length()
const 227 return (
double)
sqrt(x * x + y * y + z * z);
232 double square =
sqrt(x * x + y * y + z * z);
234 x /= square; y /= square; z /= square;
249 double random_double_01(
double a) {
250 double rnf = a * 14.434252 + a * 364.2343 + a * 4213.45352 + a * 2341.43255 + a * 254341.43535 + a * 223454341.3523534245 + 23453.423412;
251 int rni = ((int)rnf) % 100000;
252 return double(rni) / (100000.0f - 1.0f);
255 vec3f random01_fxyz() {
256 x = (double)random_double_01(x);
257 y = (double)random_double_01(y);
258 z = (double)random_double_01(z);
307 void simplification(
const ipUInt64 target_count,
309 const ipBool bVerbose =
false);
317 std::vector<ipUInt32>& deleted);
320 void update_triangles(
const ipUInt32 i0,
322 const std::vector<ipUInt32>& deleted,
326 void update_mesh(
const ipUInt32 iteration);
335 void compact_arrays(
const ipReal32* pVertexArray,
337 std::vector<ipReal32>& vVerticesArray,
338 std::vector<ipUInt32>& vFacesArray);
355 void simplify_mesh_inSitu(
Mesh3d<T>& mesh,
358 const ipBool bVerbose =
false);
361 boost::shared_ptr<Mesh3d<T>> simplify_mesh(
const Mesh3d<T>& mesh,
364 const ipBool bVerbose =
false);
368 void simplify_arrays(
const ipReal32* pVerticesArray,
375 std::vector<ipReal32>& vVerticesArray,
376 std::vector<ipUInt32>& vFacesArray);
386 std::vector<Triangle> _triangles;
389 std::vector<Vertex> _vertices;
392 std::vector<Ref> _refs;
395 std::vector<std::vector<ipBool>> _collapses;
409 #endif // __IPSDKGEOMETRY_MESHSIMPLIFICATION_H__ Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
IPSDKGEOMETRY_API Point2d< T > operator*(const ipReal64 value, const Point2d< T > &pt)
arithmetic operators on point
IPSDK_FORCEINLINE PackT sqrt(const PackT &in)
returns the square root of a pack
Definition: sqrt.h:40
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
IPSDK_FORCEINLINE PackT max(const PackT &in1, const PackT &in2)
returns the maximum of 2 packs
Definition: max.h:40
Definition: MeshSimplification.h:264
IPSDK_FORCEINLINE PackT min(const PackT &in1, const PackT &in2)
returns the minimum of 2 packs
Definition: min.h:40
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
Closed mesh associated to a triangulated boundary.
Definition: MeshSimplification.h:35
Definition: MeshSimplification.h:291
bool ipBool
Base types definition.
Definition: BaseTypes.h:47
Definition: MeshSimplification.h:64
IPSDKBASESHAPESEGMENTATION_API void normalize(ipsdk::geom::Shape2dPolygonWithHoles &polygonWithHoles)
function allowing to normalize a polygon to ensure that :
Closed mesh associated to a triangulated boundary.
Definition: Mesh3d.h:43
Definition: MeshSimplification.h:278
Definition: MeshSimplification.h:59
Closed mesh associated to a triangulated boundary.
Definition: SymmetricMatrix.h:51
float ipReal32
Base types definition.
Definition: BaseTypes.h:56
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53