Debian Codegraph @

tools/physicalModeling/mesh2faust/vega/libraries/include/verticesQueryRational.h

raw symbols SCIP
1 /*
2 This code is based on code from the Geometric Tools library,
3 which is licensed under a boost license.
4 Such usage is permitted by the boost license; for details,
5 please see the boost license below.
6 */
7
8 // Geometric Tools, LLC
9 // Copyright (c) 1998-2014
10 // Distributed under the Boost Software License, Version 1.0.
11 // http://www.boost.org/LICENSE_1_0.txt
12 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
13
14 /*************************************************************************
15 * *
16 * We release our improvements to the wildMagic code under our standard *
17 * Vega FEM license, as follows: *
18 * *
19 * Vega FEM Simulation Library Version 3.1 *
20 * *
21 * "improvements to the wildMagic library" , Copyright (C) 2016 USC *
22 * All rights reserved. *
23 * *
24 * Code author: Yijing Li *
25 * http://www.jernejbarbic.com/code *
26 * *
27 * Funding: National Science Foundation *
28 * *
29 * This library is free software; you can redistribute it and/or *
30 * modify it under the terms of the BSD-style license that is *
31 * included with this library in the file LICENSE.txt *
32 * *
33 * This library is distributed in the hope that it will be useful, *
34 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file *
36 * LICENSE.TXT for more details. *
37 * *
38 *************************************************************************/
39
40
41 #ifndef VERTICESQUERYRATIONAL_H
42 #define VERTICESQUERYRATIONAL_H
43
44 #include "rational.h"
45 #include "rVector.h"
46 #include "verticesQuery.h"
47 #include "tetKey.h"
48 #include <map>
49
50 class VerticesQueryRational : public VerticesQuery
51 {
52 public:
53 // The components of the input vertices are represented exactly as
54 // rational values.
55 VerticesQueryRational (int numVertices, const Vec3d * vertices);
56 virtual ~VerticesQueryRational ();
57
58 // run-time type information
59 virtual Type getType () const { return RATIONAL; }
60
61 virtual void addVertex(const Vec3d & v);
62
63 // Queries about the relation of a point to various geometric objects.
64
65 virtual int toPlane (int i, int v0, int v1, int v2) const;
66 virtual int toPlane (const Vec3d& test, int v0, int v1, int v2) const;
67
68 virtual int toTetrahedron (int i, int v0, int v1, int v2, int v3) const;
69 virtual int toTetrahedron (const Vec3d& test, int v0, int v1,
70 int v2, int v3) const;
71
72 virtual int toCircumsphere (int i, int v0, int v1, int v2, int v3) const;
73 virtual int toCircumsphere (const Vec3d& test, int v0, int v1, int v2, int v3) const;
74
75 virtual int toCircumsphere (int i, int v0, int v1, int v2) const;
76 virtual int toCircumsphere (const Vec3d& test, int v0, int v1, int v2) const;
77
78 // Helper functions.
79 typedef Rational<8*sizeof(double)> QRational;
80 typedef RVector3<8*sizeof(double)> QRVector;
81
82 static QRational dot (QRational& x0, QRational& y0, QRational& z0,
83 QRational& x1, QRational& y1, QRational& z1);
84
85 static QRational det3 (QRational& x0, QRational& y0, QRational& z0,
86 QRational& x1, QRational& y1, QRational& z1, QRational& x2,
87 QRational& y2, QRational& z2);
88
89 static QRational det4 (QRational& x0, QRational& y0, QRational& z0,
90 QRational& w0, QRational& x1, QRational& y1, QRational& z1,
91 QRational& w1, QRational& x2, QRational& y2, QRational& z2,
92 QRational& w2, QRational& x3, QRational& y3, QRational& z3,
93 QRational& w3);
94
95 protected:
96
97 void convert (int numIndices, int* indices) const;
98 int toPlane (const QRVector& ratTest, int v0, int v1, int v2) const;
99 int toTetrahedron (const QRVector& ratTest, int v0, int v1, int v2,
100 int v3) const;
101 int toCircumsphere (const QRVector& ratTest, int v0, int v1, int v2,
102 int v3) const;
103
104 int toCircumsphere (const QRVector& test, int v0, int v1, int v2) const;
105
106 // Caching for rational representations of the input. The conversion of
107 // floating-point numbers to Rational form is slow, so it is better to
108 // keep track of which values have been converted.
109 mutable std::vector<QRVector> rVertices;
110 mutable std::vector<bool> evaluated;
111
112 // ToPlane(x,a,b,c) > 0 <=> dot ( (x-a), cross(b-a, c-a) ) > 0
113 // This struct stores: normal = cross(b-a, c-a), d = - dot(a, cross(b-a, c-a) )
114 struct PlaneData
115 {
116 QRVector normal;
117 QRational d;
118 };
119
120 mutable std::map<OTriKey, PlaneData> planeDataMap;
121 typedef std::map<OTriKey, PlaneData> PlaneDataMap;
122 typedef std::map<OTriKey, PlaneData>::iterator PlaneDataMapIter;
123
124 struct CircumsphereData
125 {
126 QRVector center;
127 QRational r2;
128 };
129 mutable std::map<OTetKey, CircumsphereData> circumsphereDataMap;
130 typedef std::map<OTetKey, CircumsphereData> CircumsphereDataMap;
131 typedef std::map<OTetKey, CircumsphereData>::iterator CircumsphereDataMapIter;
132 };
133
134 #endif