CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GeTrMeshSimplification.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24#ifndef OD_GETRSIMPLIFICATION_H
25#define OD_GETRSIMPLIFICATION_H
26
27
28#include "OdPlatformSettings.h"
29#include "GePoint3dArray.h"
30#include "GeExtents3d.h"
31#include "Ge/GePoint2dArray.h"
32#include <set>
33#include <vector>
34
35namespace GeMesh
36{
37typedef std::pair<int, int> intPair;
38
39struct int3
40{
41 int3() { val[0] = val[1] = val[2] = 0; }
42 void set(int a) { val[0] = val[1] = val[2] = a; }
43 int operator [](unsigned int i) const
44 {
45 return val[i];
46 }
47 int& operator [](unsigned int i)
48 {
49 return val[i];
50 }
51 int val[3];
52};
53
55{
56 OdGeTr() : tagFace(-1) { nb.set(-1); tagEdge.set(-1); }
57 void replaceNb(int nbOld, int nbNew);
58
63};
64
66{
67public:
71 OdGeMesh() : m_tagMesh(0) {}
73 virtual ~OdGeMesh() {}
74
75 virtual double distanceTo(const OdGePoint3d& pt, OdGePoint3d& ptClosest, bool bPrecise) const = 0;
76 virtual int checkMeshMismatch(const OdGeMesh& mesh, OdGePoint3dArray& aPtMismatch, double tol) const = 0;
77
78public:
82};
83
85{
86public:
87 virtual double distanceTo(const OdGePoint3d& pt, OdGePoint3d& ptClosest, bool bPrecise) const ODRX_OVERRIDE;
88 virtual int checkMeshMismatch(const OdGeMesh& mesh, OdGePoint3dArray& aPtMismatch, double tol) const ODRX_OVERRIDE;
89
90 OdGeVector3d trNormal(int t, double* area = NULL) const;
92 bool walkNextTr(int& iTr, int& w, bool dir) const;
93 bool walkAroundVertex(int& iTr, int& w, int3& aux) const;
94 int getCoEdge(int t, int e) const;
97 void append(const OdGeTrMesh& mesh);
98 void clear();
99 void fillVxToTr();
101
102 void dump(FILE* f) const;
103public:
105
106 // vector to assign vertices to triangles
108};
109
111{
112 VertexPair() : m_cost(1e300) {}
113 VertexPair(int a, int b) : m_cost(1e300) { m_edge.first = a; m_edge.second = b; }
114 // is this point present in pair?
115 bool isPresent(int a) { return m_edge.first == a || m_edge.second == a; }
116 // is equal?
117 bool equal(VertexPair& pair) { return isPresent(pair.m_edge.first) && isPresent(pair.m_edge.second); }
118 void replace(int a, int b);
119 int nb(int a);
120
121 // cost (error) of contraction this pair
122 double m_cost;
123 // indices of 2 vertices
125 // position of new point (after contraction) which minimizes error
127};
128
130{
131 double m_cost;
132 int m_ind;
133 VertexPairKey(double cost, int ind) {m_cost = cost; m_ind = ind;}
134};
135
137{
138protected:
141 void computeErrorOnPair(int iPair);
142 virtual bool computeQ(int iVt) = 0;
143
144protected:
145 // vertices
147 // tolerance ^2
148 double m_eps2;
149 // max edge length
151 // quadrics to approximate error at each vertex
153 // contraction candidates
155 // vector to assign vertices to pairs
157 // map to keep pairs sorted by cost
158 std::set<VertexPairKey> m_pairMap;
159};
160
162{
163public:
165 void reset(OdGeTrMesh& trng);
166 void algo(double simpPercent);
167
168private:
169 virtual bool computeQ(int iVt) ODRX_OVERRIDE;
170 bool isEdgeValid(int t, int v);
171 bool checkEdge(int t, int v);
172 bool checkOverlap(int v1, int v2);
173 int selectPairs();
174 int contractPair();
175 void removeGarbage();
176#ifdef _DEBUG
177 bool checkVxToTr(int iVt);
178#endif
179
180private:
181 // mesh to simplificate
182 OdGeTrMesh* m_pTrng;
183 // determines the vertex's fan type (0 - closed, 1 - open, 2 - corner)
184 OdArray<int> m_fanType;
185};
186
198GE_TOOLKIT_EXPORT bool triangulateProfile(const OdGePoint2dArray& vertexSource, const std::vector<OdInt32>& inFaceData, OdArray<OdInt32>& vecTriangles, double tol = 0);
199
200GE_TOOLKIT_EXPORT bool compareMeshes(const OdGeTrMesh& meshTemplate, const OdGeTrMesh& mesh, double tolCoef, bool bDebugOutput);
201}
202
203#endif // OD_GETRSIMPLIFICATION_H
204
tol
Definition: DimVarDefs.h:2287
#define GE_TOOLKIT_EXPORT
Definition: GeExport.h:49
#define ODRX_OVERRIDE
std::set< VertexPairKey > m_pairMap
OdArray< OdArray< int > > m_vxToPair
void computeErrorOnPair(int iPair)
virtual bool computeQ(int iVt)=0
void reset(OdGePoint3dArray &vx)
void reset(OdGeTrMesh &trng)
void algo(double simpPercent)
OdGeExtents3d getExtents() const
OdGePoint3dArray m_aVx
virtual int checkMeshMismatch(const OdGeMesh &mesh, OdGePoint3dArray &aPtMismatch, double tol) const =0
virtual double distanceTo(const OdGePoint3d &pt, OdGePoint3d &ptClosest, bool bPrecise) const =0
virtual double distanceTo(const OdGePoint3d &pt, OdGePoint3d &ptClosest, bool bPrecise) const ODRX_OVERRIDE
int getCoEdge(int t, int e) const
OdArray< OdArray< intPair > > m_vxToTr
OdGeVector3d vxNormal(int v) const
void append(const OdGeTrMesh &mesh)
void dump(FILE *f) const
bool walkAroundVertex(int &iTr, int &w, int3 &aux) const
void removeUnusedVertices()
virtual int checkMeshMismatch(const OdGeMesh &mesh, OdGePoint3dArray &aPtMismatch, double tol) const ODRX_OVERRIDE
OdGeVector3d trNormal(int t, double *area=NULL) const
void removeDegenerateTriangles(double tol)
bool walkNextTr(int &iTr, int &w, bool dir) const
GLfloat GLfloat v1
Definition: gles2_ext.h:295
GLfloat f
Definition: gles2_ext.h:564
GLfloat GLfloat GLfloat v2
Definition: gles2_ext.h:296
GLfloat GLfloat GLfloat GLfloat w
Definition: gles2_ext.h:320
const GLfloat * v
Definition: gles2_ext.h:315
GE_TOOLKIT_EXPORT bool compareMeshes(const OdGeTrMesh &meshTemplate, const OdGeTrMesh &mesh, double tolCoef, bool bDebugOutput)
std::pair< int, int > intPair
GE_TOOLKIT_EXPORT bool triangulateProfile(const OdGePoint2dArray &vertexSource, const std::vector< OdInt32 > &inFaceData, OdArray< OdInt32 > &vecTriangles, double tol=0)
void replaceNb(int nbOld, int nbNew)
void replace(int a, int b)
bool equal(VertexPair &pair)
VertexPairKey(double cost, int ind)
int operator[](unsigned int i) const