RichModel.h
Go to the documentation of this file.
1 // RichModel.h: interface for the CRichModel class.
2 //
4 
5 #pragma once
6 #include "BaseModel.h"
7 #include <cassert>
8 #define _USE_MATH_DEFINES
9 #include <math.h>
10 //#include <windows.h>
11 using namespace std;
12 struct EdgePoint;
13 
14 string MyGetUserName();
15 
16 class CRichModel : public CBaseModel
17 {
18 public:
19  struct CEdge
20  {
28  double length;
29  double angleOpposite;
30  pair<double, double> coordOfOppositeVert;
31  // |unitX -unitY|
32  // |unitY unitX|
33  pair<double, double> matrixRotatedToLeftEdge;
34  pair<double, double> matrixRotatedToRightEdge;
36  {
37  indexOfOppositeVert = -1; //key
38  indexOfLeftEdge = -1;
39  indexOfRightEdge = -1;
40  indexOfFrontFace = -1;
41  angleOpposite = 2 * M_PI;
42  }
43  };
44 
45 protected:
46  void CreateEdgesFromVertsAndFaces();
47  void CollectAndArrangeNeighs();
48  void ComputeAnglesAroundVerts();
49  void ComputePlanarCoordsOfIncidentVertForEdges();
50  void ComputeNumOfHoles();
51  void ComputeNumOfComponents();
52 public:
53  CRichModel(const string &filename);
54  CRichModel(const vector<CPoint3D> &verts, const vector<CBaseModel::CFace> &faces);
55  void LoadModel();
56  void PreprocessBaseModel();
57  int SplitEdge(const EdgePoint& ep);
58  void SplitBasedOnScalarField(const vector<double>& scalarField,
59  double val,
60  const string& fileWithLargerScalars,
61  const string& fileWithSmallerScalars);
62  void SavePathToObj(const vector<EdgePoint>& pl, const string& filename) const;
63  //void SavePathToObj(const vector<CPoint3D>& pl, const string& filename) const;
64  void SaveIsolineToObj(const vector<EdgePoint>& isoline, const string& filename) const;
65  void SetEdgeLength(int leftVert, int rightVert, double newLength);
66  void FinishChangingEdgeLengths();
67  void PrintInfo(ostream& out) const;
68  double AngleSum(int vertIndex) const;
69  int GetSubindexToVert(int root, int neigh) const;
70  const CEdge& Edge(int edgeIndex) const;
71  const vector<pair<int, double> >& Neigh(int root) const;
72  //inline double Curvature(int vertIndex) const;
73  //compute the proportion by two points
74  double ProportionOnEdgeByImage(int edgeIndex, const pair<double, double> &coord) const;
75  //compute the proportion on the left edge
76  double ProportionOnLeftEdgeByImage(int edgeIndex, const pair<double, double> &coord, double proportion) const;
77  //compute the proportion on the right edge
78  double ProportionOnRightEdgeByImage(int edgeIndex, const pair<double, double> &coord, double proportion) const;
79  //compute the proportion by two points
80  double ProportionOnEdgeByImage(int edgeIndex, double x1, double y1, double x2, double y2) const;
81  pair<double, double> GetNew2DCoordinatesByRotatingAroundLeftChildEdge(int edgeIndex, const pair<double, double>& input2DCoordinates) const;
82  pair<double, double> GetNew2DCoordinatesByRotatingAroundRightChildEdge(int edgeIndex, const pair<double, double>& input2DCoordinates) const;
83  pair<double, double> GetNew2DCoordinatesByReversingCurrentEdge(int edgeIndex, const pair<double, double>& input2DCoordinates) const;
84  double DistanceToOppositeAngle(int edgeIndex, const pair<double, double>& coord) const;
85  double DistanceToLeftVert(int edgeIndex, const pair<double, double>& coord) const;
86  double DistanceToRightVert(int edgeIndex, const pair<double, double>& coord) const;
87  int GetNumOfEdges() const;
88  int GetNumOfValidDirectedEdges() const;
89  int GetNumOfTotalUndirectedEdges() const;
90  int GetNumOfGenera() const;
91  int GetNumOfIsolated() const;
92  int GetNumOfComponents() const;
93  int GetNumOfBoundries() const;
94  bool IsStronglyConvexVert(int index) const;
95  bool IsWeaklyConvexVert(int index) const;
96  bool isBoundaryVert(int index) const;
97  bool IsClosedModel() const;
98  bool IsExtremeEdge(int edgeIndex) const;
99  bool IsStartEdge(int edgeIndex) const;
100  int GetEdgeIndexFromTwoVertices(int leftVert, int rightVert) const;
101  pair<double, double> GetTwoSplitAngles(int root, EdgePoint pt1, EdgePoint pt2) const;
102  int IntersectQuery(int faceID, const pair<EdgePoint, EdgePoint>& seg1, const pair<EdgePoint, EdgePoint>& seg2, EdgePoint& intersection) const;
103  double GetMaxEdgeLength() const;
104  CPoint3D GetBarycentricCoord(CPoint3D pt, int faceID) const;
105 protected:
110  vector<CEdge> m_Edges;
111  set<int> m_UselessEdges;
112  vector<vector<pair<int, double> > > m_NeighsAndAngles;
113  //<strongconvex, weakconvex>
114  vector<pair<bool, bool>> m_FlagsForCheckingConvexVerts;
115 };
vector< CEdge > m_Edges
Definition: RichModel.h:110
pair< double, double > coordOfOppositeVert
Definition: RichModel.h:30
int indexOfReverseEdge
Definition: RichModel.h:26
int m_nIsolatedVerts
Definition: RichModel.h:107
vector< pair< bool, bool > > m_FlagsForCheckingConvexVerts
Definition: RichModel.h:114
pair< double, double > matrixRotatedToLeftEdge
Definition: RichModel.h:33
int m_nBoundries
Definition: RichModel.h:106
double angleOpposite
Definition: RichModel.h:29
int indexOfOppositeVert
Definition: RichModel.h:23
vector< vector< pair< int, double > > > m_NeighsAndAngles
Definition: RichModel.h:112
int m_nComponents
Definition: RichModel.h:108
double m_maxEdgeLength
Definition: RichModel.h:109
set< int > m_UselessEdges
Definition: RichModel.h:111
string MyGetUserName()
pair< double, double > matrixRotatedToRightEdge
Definition: RichModel.h:34


co_scan
Author(s):
autogenerated on Mon Feb 28 2022 23:00:48