EdgePoint.h
Go to the documentation of this file.
1 #pragma once
2 #include "RichModel.h"
3 #include <fstream>
4 using namespace std;
5 struct EdgePoint
6 {
7  bool isVertex;
8  int index;
9  double proportion; //[0 --> left endpoint; 1 --> right endpoint]
11  {
12  index = -1;
13  }
14  EdgePoint(int index) : index(index), isVertex(true){}
15  EdgePoint(int index, double proportion) : index(index), proportion(proportion), isVertex(false) {}
16  EdgePoint(const CRichModel& model, int leftVert, int rightVert, double proportion) : proportion(proportion), isVertex(false)
17  {
18  index = model.GetEdgeIndexFromTwoVertices(leftVert, rightVert);
19  }
20  bool operator==(const EdgePoint& other) const
21  {
22  if (isVertex)
23  return isVertex == other.isVertex && index == other.index;
24  return isVertex == other.isVertex && index == other.index && proportion == other.proportion;
25  }
26  bool operator!=(const EdgePoint& other) const
27  {
28  return !(*this == other);
29  }
30  void Reverse(const CRichModel& model)
31  {
32  if (isVertex)
33  return;
34  index = model.Edge(index).indexOfReverseEdge;
35  proportion = 1 - proportion;
36  }
37  double GetNumbering(const CRichModel& model, int faceID) const
38  {
39  if (isVertex)
40  {
41  for (int i = 0; i < 3; ++i)
42  if (model.Face(faceID)[i] == index)
43  return i;
44  }
45  EdgePoint copy(*this);
46  if (model.Edge(copy.index).indexOfFrontFace != faceID)
47  copy.Reverse(model);
48  for (int i = 0; i < 3; ++i)
49  {
50  if (model.Edge(copy.index).indexOfLeftVert == model.Face(faceID)[i])
51  return i + copy.proportion;
52  }
53  return -1;
54  }
55  CPoint3D Get3DPoint(const CRichModel& model) const
56  {
57  if (isVertex)
58  return model.Vert(index);
59  return (1 - proportion) * model.Vert(model.Edge(index).indexOfLeftVert)
60  + proportion * model.Vert(model.Edge(index).indexOfRightVert);
61  }
62  CPoint3D GetShiftPoint(const CRichModel& model) const
63  {
64  if (isVertex)
65  return model.GetShiftVertex(index);
66  return (1 - proportion) * model.GetShiftVertex(model.Edge(index).indexOfLeftVert)
67  + proportion * model.GetShiftVertex(model.Edge(index).indexOfRightVert);
68  }
69  bool operator <(const EdgePoint& other) const
70  {
71  if (isVertex == false && other.isVertex == true)
72  return true;
73  if (isVertex == true && other.isVertex == false)
74  return false;
75  if (index < other.index)
76  return true;
77  if (index > other.index)
78  return false;
79  if (proportion < other.proportion)
80  return true;
81  if (proportion > other.proportion)
82  return false;
83  return false;
84  }
85  friend ostream& operator <<(ostream& out, const EdgePoint& ep)
86  {
87  if (ep.isVertex)
88  out << "v " << ep.index << " ";
89  else
90  out << "e " << ep.index << " " << ep.proportion << " ";
91  return out;
92  }
93 };
94 //
95 //void SavePathToObj(const CRichModel& model, const vector<EdgePoint>& pl, const char* filename);
96 //void SaveIsolineToObj(const CRichModel& model, const vector<EdgePoint>& isoline, const char* filename);
bool operator!=(const EdgePoint &other) const
Definition: EdgePoint.h:26
double GetNumbering(const CRichModel &model, int faceID) const
Definition: EdgePoint.h:37
EdgePoint(const CRichModel &model, int leftVert, int rightVert, double proportion)
Definition: EdgePoint.h:16
std::ostream & operator<<(std::ostream &s, const Packet16uc &v)
double proportion
Definition: EdgePoint.h:9
const CEdge & Edge(int edgeIndex) const
Definition: RichModel.cpp:669
bool operator==(const EdgePoint &other) const
Definition: EdgePoint.h:20
int GetEdgeIndexFromTwoVertices(int leftVert, int rightVert) const
Definition: RichModel.cpp:756
CPoint3D GetShiftPoint(const CRichModel &model) const
Definition: EdgePoint.h:62
int index
Definition: EdgePoint.h:8
int indexOfReverseEdge
Definition: RichModel.h:26
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator<(const half &a, const half &b)
Definition: Half.h:246
EdgePoint(int index, double proportion)
Definition: EdgePoint.h:15
EdgePoint()
Definition: EdgePoint.h:10
const CPoint3D & Vert(int vertIndex) const
Definition: BaseModel.h:90
CPoint3D GetShiftVertex(int indexOfVert) const
Definition: BaseModel.cpp:544
const CFace & Face(int faceIndex) const
Definition: BaseModel.h:100
EdgePoint(int index)
Definition: EdgePoint.h:14
CPoint3D Get3DPoint(const CRichModel &model) const
Definition: EdgePoint.h:55
void Reverse(const CRichModel &model)
Definition: EdgePoint.h:30
bool isVertex
Definition: EdgePoint.h:7


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