4 #ifndef U3D_TRIANGLED_ABSTRACT_SURFACE_HPP_
5 #define U3D_TRIANGLED_ABSTRACT_SURFACE_HPP_
7 #include <mth/u3d_point.hpp>
8 #include <mth/u3d_triangle.hpp>
9 #include "mth/u3d_math_abstract_surface.hpp"
10 #include "mth/u3d_triangled_abstract_surface.hpp"
19 #define U3D_MIN_TRIANGLE_SIZE 50 //U3D_EPS_LENGTH * 10.;
22 enum U3D_COLOR {WHITE, BLACK};
41 virtual void addPoint(
U3dPoint*) = 0;
42 virtual bool removePoint(
int pointId) = 0;
43 virtual void movePoint(
int pointId,
double x,
double y,
double z) = 0;
45 virtual class U3dBox getBox() const = 0;
61 else { triangle = m_triangles[id];
return true; }
88 else { point =
U3dPoint(*m_tps[
id]);
return true; }
91 const U3dPoint*
getPoint(
int id)
const throw(std::out_of_range) {
return m_tps.at(
id); }
97 bool getPoint(
int id,
double &x,
double &y,
double &z)
101 x = m_tps[id]->getX();
102 y = m_tps[id]->getY();
103 z = m_tps[id]->getZ();
150 virtual void calculateTrPlanes();
155 U3dTrianglesAr m_triangles;
157 U3dPointsAr m_initPoints;
159 std::set<int> m_actTrNums;
180 My2DPoint(
double ix,
double iy) : x(ix), y(iy) {};
181 double distance(
const My2DPoint& other)
const;
182 double getX()
const {
return x; };
183 double getY()
const {
return y; };
191 MyHVector(
double aa,
double bb, My2DPoint point) : a(aa), b(bb), p(point) {};
192 My2DPoint intersect(
const MyHVector& v)
const throw(std::overflow_error);
193 double getA()
const {
return a; };
194 double getB()
const {
return b; };
195 double getX()
const {
return p.getX(); };
196 double getY()
const {
return p.getY(); };
197 const My2DPoint& getP()
const {
return p; };
206 Edge(My2DPoint* s, My2DPoint* d);
208 bool isPointOnRight(
const My2DPoint& p)
const;
209 const MyHVector& getPerpendicular()
const {
return hvec; };
210 bool operator==(
const Edge& other)
const;
211 My2DPoint* source()
const {
return sorc; };
212 My2DPoint* dest()
const {
return dst; };
213 double getLength() {
return sorc->distance(*dst); };
215 My2DPoint *sorc, *dst;
221 double vectOP[3], vectOQ[3];
222 double lengthOP, lengthOQ;
224 typedef std::map< My2DPoint*, unsigned> T_2d_3d_Assigns;
225 T_2d_3d_Assigns assigns;
226 std::vector<U3dTriangle*> my_triangles;
228 typedef std::list<Edge> Front;
231 void addNewEdge(
const Edge& edge);
232 const Edge* getNextEdge();
233 Front::iterator itrNextEdge;
235 My2DPoint* vertexes[3];
237 void init(
const U3dPoint& p0,
const U3dPoint& p1,
double A,
double B,
double C);
244 My2DPoint* add3DPoint(
unsigned index,
const U3dPoint* p);
245 const std::vector<U3dTriangle*>& generateU3dTriangles() { triangulate();
return my_triangles; }
253 friend class Intersect;
258 const double& mx,
const double& my,
const double& mz);
261 bool incIfEqual(Intersect& other);
262 const std::vector<int>& triangles()
const {
return m_triangs; };
263 const double& getX()
const {
return x; };
264 const double& getY()
const {
return y; };
265 const double& getZ()
const {
return z; };
266 const int& ind1()
const {
return index1; };
267 const int& ind2()
const {
return ind2vec.front(); };
268 const int& ind3()
const {
return ind3vec.front(); };
270 bool find(
const double& xin,
const double& yin,
const double& zin,
271 double& xother,
double& yother,
double& zother);
276 std::list<int> ind2vec, ind3vec;
277 std::vector<int> m_triangs;
285 struct SegmentChecked {
287 bool operator< (
const SegmentChecked& other)
const {
288 if (ind1 < other.ind1)
return true;
289 if (ind1 > other.ind1)
return false;
290 return ind2 < other.ind2;
303 int getTrPointIndex(
const int& trnum,
const double& x,
const double& y,
304 const double& z,
int& index)
const;
313 #endif // U3D_TRIANGLED_ABSTRACT_SURFACE_HPP_
const U3dPoint * getPoint(int id) const
Definition: u3d_triangled_abstract_surface.hpp:91
const U3dTriangle * getTriangle(int id) const
Definition: u3d_triangled_abstract_surface.hpp:52
Definition: u3d_math_abstract_surface.hpp:11
void getInitialPoints(U3dPointsAr &ps)
Definition: u3d_triangled_abstract_surface.hpp:118
Definition: u3d_triangled_abstract_surface.hpp:31
virtual void getIntersections(U3dPoint p0, U3dPoint p1, std::vector< int > &int_trIds, U3dPointsAr &int_points)
bool getPoint(int id, double &x, double &y, double &z)
Definition: u3d_triangled_abstract_surface.hpp:97
Definition: u3d_box.hpp:24
int getTrianglesNum() const
Definition: u3d_triangled_abstract_surface.hpp:68
Definition: u3d_triangle.hpp:18
Definition: geometry.H:16
bool isTriangulated()
Definition: u3d_triangled_abstract_surface.hpp:139
const U3dPointsAr & getInitialPoints() const
Definition: u3d_triangled_abstract_surface.hpp:123
void severance(U3dTriangledAbstractSurface *other, const U3D_COLOR &)
virtual bool getSideColor(const U3dPoint &p, U3D_COLOR &u3dcolor) const
void setWhitePoint(const U3dPoint &p)
Definition: u3d_triangled_abstract_surface.hpp:76
Definition: u3d_point.hpp:16
int getPointsNum()
Definition: u3d_triangled_abstract_surface.hpp:109
U3dPoint getWhitePoint() const
Definition: u3d_triangled_abstract_surface.hpp:79
bool m_is_triangulated
Definition: u3d_triangled_abstract_surface.hpp:163
void getPoints(U3dPointsAr &ps)
Definition: u3d_triangled_abstract_surface.hpp:112
Definition: u3d_triangled_abstract_surface.hpp:172
const std::set< int > & getActTrNums()
Definition: u3d_triangled_abstract_surface.hpp:143