2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008-2013 enGits GmbH +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #ifndef CADINTERFACE_H
24 #define CADINTERFACE_H
27 #include "meshpartition.h"
34 private: // attributes
36 QString m_Name
; ///< The name of the CAD interface
39 protected: // attributes
41 vtkUnstructuredGrid
* m_FGrid
; ///< the foreground grid to project
42 MeshPartition m_FPart
; ///< MeshPartition for the foreground grid
43 QVector
<vec3_t
> m_RayPoints
; ///< template for ray cloud to snap points
44 vec3_t m_LastNormal
; ///< last surface normal which was encountered
45 double m_LastRadius
; ///< last surface radius which was encountered
46 bool m_Failed
; ///< did the last operation fail
52 * @brief issue an error message about not implemented functionality
53 * Not all functionality will be implemented in every derived class of CadInterface.
54 * Certain meshing processes might still work. For this reason an error message will be displayed,
55 * rather than preventing instantiation by using abstract methods (=0).
57 void notImplemented();
61 * The CAD interface should be given a name. This will be used to display messages.
62 * A name could, for example, be "triangulated geometry CAD interface".
63 * @param name the name to set
65 void setName(QString name
) { m_Name
= name
; }
70 enum HitType
{ Miss
, HitIn
, HitOut
};
73 //enum PositionType { Inside, Outside, Surface };
80 void setForegroundGrid(vtkUnstructuredGrid
* grid
);
82 QString
name() { return m_Name
; }
85 * @brief vital interface method to the geometry
86 * This method is a major part of interfacing geometries. The idea is to provide something like
87 * a virtual laser scanner. The concept of a ray-tracing interface has been taken from the
88 * open-source CAD software BRL-CAD (see http://brlcad.org).
89 * @param x the origin of the ray
90 * @param v the direction of the ray
91 * @param x_hit if the ray hits this contains the intersection point between ray and geometry
92 * @param n_hit if the ray hits this contains the geometry normal vector at the intersection point
93 * @param r if the ray hits this contains the surface radius at the intersection point
94 * @return the result (Miss, HitIn, HitOut)
96 virtual HitType
shootRay(vec3_t x
, vec3_t v
, vec3_t
&x_hit
, vec3_t
&n_hit
, double &r
) { notImplemented(); }
99 * @brief snap a point to the geometry
100 * If you want to snap a node of the grid, consider using snapNode because it might be faster.
101 * Curvature correction only applies to certain geometric models (e.g. STL).
102 * @param x the position of the point to snap
103 * @param correct_curvature flag to determine if corveture correction shall be used
104 * @return the snapped position
106 virtual vec3_t
snap(vec3_t x
, bool correct_curvature
= false);
109 * @brief snap a node of the foreground grid
110 * Curvature correction only applies to certain geometric models (e.g. STL).
111 * @param id_node the node to snap
112 * @param correct_curvature flag to determine if corveture correction shall be used
113 * @return the snapped position
115 virtual vec3_t
snapNode(vtkIdType id_node
, bool correct_curvature
= false);
118 * @brief snap a node of the foreground grid using an alternate position
119 * Curvature correction only applies to certain geometric models (e.g. STL).
120 * @param id_node the node to snap
121 * @param x the position to snap
122 * @param correct_curvature flag to determine if curvature correction shall be used
123 * @return the snapped position
125 virtual vec3_t
snapNode(vtkIdType id_node
, vec3_t x
, bool correct_curvature
= false);
128 * @brief project a point onto the geometry
129 * If you want to project a node of the mesh, consider using projectNode because it might be faster.
130 * This methods project in forward and backward direction and takes the closer point.
131 * Curvature correction only applies to certain geometric models (e.g. STL).
132 * @param x the position of the point to project
133 * @param v the direction of projection
134 * @param strict_direction if set to true only the forward direction will be considered
135 * @param correct_curvature set this to true if you want to use curvature correction
136 * @return the projected point
138 virtual vec3_t
project(vec3_t x
, vec3_t v
, bool strict_direction
= false, bool correct_curvature
= false);
141 * @brief project a node of the foreground mesh onto the geometry
142 * This methods project in forward and backward direction and takes the closer point.
143 * Curvature correction only applies to certain geometric models (e.g. STL).
144 * @param id_node the node to project
145 * @param strict_direction if set to true only the forward direction will be considered
146 * @param correct_curvature set this to true if you want to use curvature correction
147 * @return the projected point
149 virtual vec3_t
projectNode(vtkIdType id_node
, bool strict_direction
= false, bool correct_curvature
= false);
152 * @brief project a node of the foreground mesh onto the geometry using an alternate position
153 * This methods project in forward and backward direction and takes the closer point.
154 * Curvature correction only applies to certain geometric models (e.g. STL).
155 * @param id_node the node to project
156 * @param x the position to project
157 * @param strict_direction if set to true only the forward direction will be considered
158 * @param correct_curvature set this to true if you want to use curvature correction
159 * @return the projected point
161 virtual vec3_t
projectNode(vtkIdType id_node
, vec3_t x
, bool strict_direction
= false, bool correct_curvature
= false);
164 * @brief project a node of the foreground mesh onto the geometry using an alternate position and direction
165 * This methods project in forward and backward direction and takes the closer point.
166 * Curvature correction only applies to certain geometric models (e.g. STL).
167 * @param id_node the node to project
168 * @param x the position to project
169 * @param v the direction of projection
170 * @param strict_direction if set to true only the forward direction will be considered
171 * @param correct_curvature set this to true if you want to use curvature correction
172 * @return the projected point
174 virtual vec3_t
projectNode(vtkIdType id_node
, vec3_t x
, vec3_t v
, bool strict_direction
= false, bool correct_curvature
= false);
176 virtual vec3_t
correctCurvature(vec3_t x
) { return x
; }
178 virtual double getRadius(vtkIdType id_node
);
180 //vtkIdType lastProjTriangle() { return -1; } /// delete this ???
182 bool failed() { return m_Failed
; }
183 vec3_t
getLastNormal() { return m_LastNormal
; }
184 double getLastRadius() { return m_LastRadius
; }
188 #endif // CADINTERFACE_H