libsurf
Programmer's Documentation

iges124.h (r6227/r5619)
1 
2 /* Copyright (C) 2015 David Eller <david@larosterna.com>
3  *
4  * Commercial License Usage
5  * Licensees holding valid commercial licenses may use this file in accordance
6  * with the terms contained in their respective non-exclusive license agreement.
7  * For further information contact david@larosterna.com .
8  *
9  * GNU General Public License Usage
10  * Alternatively, this file may be used under the terms of the GNU General
11  * Public License version 3.0 as published by the Free Software Foundation and
12  * appearing in the file gpl.txt included in the packaging of this file.
13  */
14 
15 #ifndef SURF_IGES124_H
16 #define SURF_IGES124_H
17 
18 #include "igesentity.h"
19 #include <genua/smatrix.h>
20 
29 {
30 public:
31 
33  IgesTrafoMatrix() : IgesEntity(124) { rp(0,0)=rp(1,1)=rp(2,2)=1.0; }
34 
36  void setup(const double rot[], const double trans[]) {
37  memcpy(rp.pointer(), rot, 9*sizeof(double));
38  memcpy(tp.pointer(), trans, 3*sizeof(double));
39  }
40 
42  const double *rotation() const {return rp.pointer();}
43 
45  const double *translation() const {return tp.pointer();}
46 
48  const double & rotation(uint i, uint j) const {return rp(i,j);}
49 
51  const double & translation(uint i) const {return tp[i];}
52 
54  double & rotation(uint i, uint j) {return rp(i,j);}
55 
57  double & translation(uint i) {return tp[i];}
58 
60  void toMatrix(Mtx44 & m) const {
61  for (int j=0; j<3; ++j) {
62  m(j,3) = tp[j];
63  for (int i=0; i<3; ++i)
64  m(i,j) = rp(i,j);
65  }
66  m(3,0) = m(3,1) = m(3,2) = 0.0;
67  m(3,3) = 1.0;
68  }
69 
71  void toMatrix(Mtx34 & m) const {
72  for (int j=0; j<3; ++j) {
73  m(j,3) = tp[j];
74  for (int i=0; i<3; ++i)
75  m(i,j) = rp(i,j);
76  }
77  }
78 
80  template <class MatrixType>
81  void fromMatrix(const MatrixType & m) {
82  for (int j=0; j<3; ++j) {
83  tp[j] = m(j,3);
84  for (int i=0; i<3; ++i)
85  rp(i,j) = m(i,j);
86  }
87  }
88 
90  Vct3 forward(const Vct3 & p) const {
91  Vct3 t;
92  t[0] = rp(0,0)*p[0] + rp(0,1)*p[1] + rp(0,2)*p[2] + tp[0];
93  t[1] = rp(1,0)*p[0] + rp(1,1)*p[1] + rp(1,2)*p[2] + tp[1];
94  t[2] = rp(2,0)*p[0] + rp(2,1)*p[1] + rp(2,2)*p[2] + tp[2];
95  return t;
96  }
97 
99  void definition(IgesFile & file);
100 
102  uint parse(const std::string & pds, const Indices & vpos);
103 
104 public:
105 
108 
111 };
112 
113 #endif // IGES124_H
Vct3 forward(const Vct3 &p) const
transform a single point
Definition: iges124.h:90
Type * pointer()
const double & rotation(uint i, uint j) const
access rotation
Definition: iges124.h:48
void definition(IgesFile &file)
assemble definition
Definition: iges124.cpp:18
double & translation(uint i)
access translation
Definition: iges124.h:57
void toMatrix(Mtx34 &m) const
convert to 3x4 transformation matrix
Definition: iges124.h:71
Base class for entities in IGES files.
Definition: igesentity.h:32
IGES 124: Transformation matrix.
Definition: iges124.h:28
uint parse(const std::string &pds, const Indices &vpos)
fetch data from string, return number of parameter values used
Definition: iges124.cpp:38
Main interface to IGES files.
Definition: igesfile.h:32
SMatrix< 3, 3, double > rp
rotation matrix
Definition: iges124.h:107
IgesTrafoMatrix()
create undefined
Definition: iges124.h:33
const double & translation(uint i) const
access translation
Definition: iges124.h:51
void toMatrix(Mtx44 &m) const
convert to 4x4 transformation matrix
Definition: iges124.h:60
const double * translation() const
access translation vector
Definition: iges124.h:45
Type * pointer()
void fromMatrix(const MatrixType &m)
convert from 3x4 transformation matrix
Definition: iges124.h:81
void setup(const double rot[], const double trans[])
set pointer to rotation matrix and translation vector
Definition: iges124.h:36
const double * rotation() const
access rotation matrix (column major)
Definition: iges124.h:42
SVector< 3, double > tp
translation vector
Definition: iges124.h:110
double & rotation(uint i, uint j)
access rotation
Definition: iges124.h:54
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5