/
ComplexGeoData.h
175 lines (154 loc) · 6.63 KB
/
ComplexGeoData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef _AppComplexGeoData_h_
#define _AppComplexGeoData_h_
#include <Base/Placement.h>
#include <Base/Persistence.h>
#include <Base/Handle.h>
#include <Base/Matrix.h>
#include <Base/BoundBox.h>
#include <Base/Rotation.h>
#ifdef __GNUC__
# include <stdint.h>
#endif
namespace Data
{
/** Segments
* Subelement type of the ComplexGeoData type
* It is used to split an object in further sub-parts.
*/
class AppExport Segment: public Base::BaseClass
{
TYPESYSTEM_HEADER();
public:
virtual ~Segment(){}
virtual std::string getName() const=0;
};
/** ComplexGeoData Object
*/
class AppExport ComplexGeoData: public Base::Persistence, public Base::Handled
{
TYPESYSTEM_HEADER();
public:
struct Line {uint32_t I1; uint32_t I2;};
struct Facet {uint32_t I1; uint32_t I2; uint32_t I3;};
/// Constructor
ComplexGeoData(void);
/// Destructor
virtual ~ComplexGeoData();
/** @name Subelement management */
//@{
/** Sub type list
* List of different subelement types
* its NOT a list of the subelements itself
*/
virtual std::vector<const char*> getElementTypes(void) const=0;
virtual unsigned long countSubElements(const char* Type) const=0;
/// get the subelement by type and number
virtual Segment* getSubElement(const char* Type, unsigned long) const=0;
/// get subelement by combined name
virtual Segment* getSubElementByName(const char* Name) const;
/** Get lines from segment */
virtual void getLinesFromSubelement(
const Segment*,
std::vector<Base::Vector3d> &Points,
std::vector<Line> &lines) const;
/** Get faces from segment */
virtual void getFacesFromSubelement(
const Segment*,
std::vector<Base::Vector3d> &Points,
std::vector<Base::Vector3d> &PointNormals,
std::vector<Facet> &faces) const;
//@}
/** @name Placement control */
//@{
/** Applies an additional transformation to the current transformation. */
void applyTransform(const Base::Matrix4D& rclTrf);
/** Applies an additional translation to the current transformation. */
void applyTranslation(const Base::Vector3d&);
/** Applies an additional rotation to the current transformation. */
void applyRotation(const Base::Rotation&);
/** Override the current transformation with a placement
* using the setTransform() method.
*/
void setPlacement(const Base::Placement& rclPlacement);
/** Return the current transformation as placement using
* getTransform().
*/
Base::Placement getPlacement() const;
/** Override the current transformation with the new one.
* This method has to be handled by the child classes.
* the actual placement and matrix is not part of this class.
*/
virtual void setTransform(const Base::Matrix4D& rclTrf)=0;
/** Return the current matrix
* This method has to be handled by the child classes.
* the actual placement and matrix is not part of this class.
*/
virtual Base::Matrix4D getTransform(void) const = 0;
//@}
/** @name Modification */
//@{
/// Applies a transformation on the real geometric data type
virtual void transformGeometry(const Base::Matrix4D &rclMat) = 0;
//@}
/** @name Getting basic geometric entities */
//@{
/// Get the bound box
virtual Base::BoundBox3d getBoundBox(void)const=0;
/** Get point from line object intersection */
virtual Base::Vector3d getPointFromLineIntersection(
const Base::Vector3f& base,
const Base::Vector3f& dir) const;
/** Get points from object with given accuracy */
virtual void getPoints(std::vector<Base::Vector3d> &Points,
std::vector<Base::Vector3d> &Normals,
float Accuracy, uint16_t flags=0) const;
/** Get lines from object with given accuracy */
virtual void getLines(std::vector<Base::Vector3d> &Points,std::vector<Line> &lines,
float Accuracy, uint16_t flags=0) const;
/** Get faces from object with given accuracy */
virtual void getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &faces,
float Accuracy, uint16_t flags=0) const;
/** Get the center of gravity
* If this method is implemented then true is returned and the center of gravity.
* The default implementation only returns false.
*/
virtual bool getCenterOfGravity(Base::Vector3d& center) const;
//@}
protected:
/// from local to outside
inline Base::Vector3d transformToOutside(const Base::Vector3f& vec) const
{
return getTransform() * Base::Vector3d(vec.x,vec.y,vec.z);
}
/// from local to inside
inline Base::Vector3f transformToInside(const Base::Vector3d& vec) const
{
Base::Matrix4D tmpM(getTransform());
tmpM.inverse();
Base::Vector3d tmp = tmpM * vec;
return Base::Vector3f((float)tmp.x,(float)tmp.y,(float)tmp.z);
}
};
} //namespace App
#endif