libsurf
Programmer's Documentation

polysplinesurf.h (r6227/r5385)
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_POLYSPLINESURF_H
16 #define SURF_POLYSPLINESURF_H
17 
18 #include <genua/splinebasis.h>
19 #include "surface.h"
20 
21 class StepFile;
22 class StepEntity;
24 class IgesFile;
25 struct IgesDirEntry;
26 class AbstractCurve;
27 class TriMesh;
28 
42 class PolySplineSurf : public Surface
43 {
44 public:
45 
47  enum GridCompat {Incompatible=0, North2South,
48  South2North, East2West, West2East};
49 
51  PolySplineSurf(const std::string & s = "") : Surface(s),
52  ukfront(0.0), ukback(1.0), vkfront(0.0), vkback(1.0),
53  ustart(0.0), uend(1.0), vstart(0.0), vend(1.0) {}
54 
56  void interpolate(const Vector &u, const Vector &v, const PointGrid<3> &grid,
57  int udeg=3, int vdeg=3);
58 
60  void approximate(const Vector &u, const Vector &v, const PointGrid<3> &grid,
61  int ncu, int ncv, int udeg=3, int vdeg=3);
62 
64  Vct3 eval(Real u, Real v) const;
65 
67  Vct3 derive(Real u, Real v, uint du, uint dv) const;
68 
70  void plane(Real u, Real v, Vct3 & S, Vct3 & Su, Vct3 & Sv) const;
71 
73  void apply();
74 
76  void initGridPattern(Vector &up, Vector &vp) const;
77 
79  void dimStats(DimStat &stat) const;
80 
82  void simpleMesh(PointGrid<3,float> & pgrid,
83  PointGrid<3,float> & ngrid, uint pu=2, uint pv=2) const;
84 
86  void simpleMesh(TriMesh & msh, uint pu=2, uint pv=2, int tag=0) const;
87 
89  static GridCompat compatible(const PolySplineSurf & a,
90  const PolySplineSurf & b, Real tol=1e-6);
91 
93  XmlElement toXml(bool share=false) const;
94 
96  void fromXml(const XmlElement & xe);
97 
99  bool fromStep(const StepFile & file, const StepBSplineSurfaceWithKnots *ep);
100 
102  bool fromIges(const IgesFile & file, const IgesDirEntry & entry);
103 
105  int toIges(IgesFile & file, int tfi = 0) const;
106 
108  Surface *clone() const;
109 
111  void knotScale(AbstractCurve & c) const;
112 
113 protected:
114 
116  void evalBasisGrid(const Vector &u, const Vector &v, Matrix &A) const;
117 
119  void toControlGrid(int nu, int nv, const Matrix &b);
120 
122  Real umap(Real ux) const {
123  return clamp(ustart + ux*(uend-ustart), 0.0, 1.0);
124  }
125 
127  Real vmap(Real vx) const {
128  return clamp(vstart + vx*(vend-vstart), 0.0, 1.0);
129  }
130 
132  void mappedPlane(Real u, Real v, Vct3 & S, Vct3 & Su, Vct3 & Sv) const;
133 
134 protected:
135 
138 
141 
143  Real ukfront, ukback, vkfront, vkback;
144 
146  Real ustart, uend, vstart, vend;
147 };
148 
149 typedef boost::shared_ptr<PolySplineSurf> PolySplineSurfPtr;
150 
151 #endif
Real vmap(Real vx) const
map v parameter to internal range
Definition: polysplinesurf.h:127
Base class for all curve objects.
Definition: abstractcurve.h:31
Real ukfront
original range of knot values
Definition: polysplinesurf.h:143
Real ustart
parameter region
Definition: polysplinesurf.h:146
Polynomial spline surface.
Definition: polysplinesurf.h:42
Real umap(Real ux) const
map u parameter to internal range
Definition: polysplinesurf.h:122
PointGrid< 3 > cp
control point grid
Definition: polysplinesurf.h:140
Data in each directory entry of an IGES file.
Definition: igesdirentry.h:31
Main interface to IGES files.
Definition: igesfile.h:32
Vct3 derive(Real u, Real v, uint du, uint dv) const
derive at (u,v)
Definition: polysplinesurf.cpp:199
void dimStats(DimStat &stat) const
compute statistics
Definition: polysplinesurf.cpp:169
void mappedPlane(Real u, Real v, Vct3 &S, Vct3 &Su, Vct3 &Sv) const
evaluate first derivatives in mapped domain [0,1]x[0,1]
Definition: polysplinesurf.cpp:295
void knotScale(AbstractCurve &c) const
transform a parameter-space curve read from IGES
Definition: polysplinesurf.cpp:491
void interpolate(const Vector &u, const Vector &v, const PointGrid< 3 > &grid, int udeg=3, int vdeg=3)
interpolate spline surface from grid
Definition: polysplinesurf.cpp:72
int toIges(IgesFile &file, int tfi=0) const
append to IGES file and return the directory entry index, if implemented
Definition: polysplinesurf.cpp:498
Vct3 eval(Real u, Real v) const
evaluation interface
Definition: polysplinesurf.cpp:176
void initGridPattern(Vector &up, Vector &vp) const
overloaded grid pattern initialization
Definition: polysplinesurf.cpp:572
void plane(Real u, Real v, Vct3 &S, Vct3 &Su, Vct3 &Sv) const
compute point and tangent derivatives at (u,v), for efficiency
Definition: polysplinesurf.cpp:226
bool fromStep(const StepFile &file, const StepBSplineSurfaceWithKnots *ep)
extract from STEP entity id
Definition: polysplinesurf.cpp:537
void toControlGrid(int nu, int nv, const Matrix &b)
recover control points from linear system solution
Definition: polysplinesurf.cpp:59
Surface * clone() const
generate a clone
Definition: polysplinesurf.cpp:670
Definition: step_ap203.h:5069
static GridCompat compatible(const PolySplineSurf &a, const PolySplineSurf &b, Real tol=1e-6)
compute control point grid compatibility
Definition: polysplinesurf.cpp:329
Surface interface.
Definition: surface.h:37
void fromXml(const XmlElement &xe)
XML input.
Definition: polysplinesurf.cpp:411
Common base class for all STEP entities.
Definition: stepentity.h:31
GridCompat
control point grid compatibility
Definition: polysplinesurf.h:47
SplineBasis ub
spline bases in two directions
Definition: polysplinesurf.h:137
void approximate(const Vector &u, const Vector &v, const PointGrid< 3 > &grid, int ncu, int ncv, int udeg=3, int vdeg=3)
approximate spline surface from grid with a given control grid size
Definition: polysplinesurf.cpp:113
STEP File.
Definition: stepfile.h:44
void evalBasisGrid(const Vector &u, const Vector &v, Matrix &A) const
evaluate spline bases on grid (interpolation/approximation)
Definition: polysplinesurf.cpp:34
XmlElement toXml(bool share=false) const
XML output.
Definition: polysplinesurf.cpp:381
PolySplineSurf(const std::string &s="")
construct named spline surface
Definition: polysplinesurf.h:51
void apply()
coordinate transformation
Definition: polysplinesurf.cpp:321
void simpleMesh(PointGrid< 3, float > &pgrid, PointGrid< 3, float > &ngrid, uint pu=2, uint pv=2) const
create simple discretization for display purposes
Definition: polysplinesurf.cpp:604
bool fromIges(const IgesFile &file, const IgesDirEntry &entry)
extract from IGES entity 128
Definition: polysplinesurf.cpp:441
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5