1 /* 2 XLiFE++ is an extended library of finite elements written in C++ 3 Copyright (C) 2014 Lunéville, Eric; Kielbasiewicz, Nicolas; Lafranche, Yvon; Nguyen, Manh-Ha; Chambeyron, Colin 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 You should have received a copy of the GNU General Public License 14 along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16 17 /*! 18 \file geometries3D.hpp 19 \authors Y. Lafranche, N. Kielbasiewicz 20 \since 18 oct 2012 21 \date 30 jul 2015 22 23 \brief Definition of the classes corresponding to 3D canonical geometrical shapes. 24 25 Geometries are separated into 3 categories : 26 - Curves 27 - Surfaces 28 - Volumes 29 30 It is quite easy to find in which category a geometry is, according to their mathematical 31 definition, but they are some exceptions : 32 - Cylinder and Cone are surfaces but can also represent volumes inside 33 - Ellipse is a closed curve or the surface inside (whereas there is the 34 distinction Circle / Disk) 35 - Ellipsoid is a closed surface or the volume inside (whereas there is the 36 distinction Sphere / Ball) 37 38 It becomes all the more tricky than if we respect the geometrical hierarchy, we will derive a 39 prism (semantically 3D) from a cylinder (2D or 3D) or a pyramid (semantically 3D) from a cone. 40 Another example is the general definition of a cylinder, from a surface and an axis : it supposes 41 that the basis is a surface. But ellipses are supposed to be curves !!! 42 43 This is the reason why we chose to defines ellipses as surfaces, ellipsoids as volumes (coherence) and cylinders 44 and cones as volumes. 45 46 */ 47 48 #ifndef GEOMETRIES_3D_HPP 49 #define GEOMETRIES_3D_HPP 50 51 #include "Geometry.hpp" 52 53 namespace xlifepp 54 { 55 56 /*! 57 \class Volume 58 base class for 3D geometries 59 */ 60 class Volume : public Geometry 61 { 62 public: 63 //! default constructor for 3D geometries 64 Volume(); 65 66 protected: 67 //@{ 68 //! true constructor functions 69 void buildParam(const Parameter& p); 70 void buildDefaultParam(ParameterKey key); 71 std::set<ParameterKey> getParamsKeys(); 72 //@} 73 74 public: Volume(const Volume & v)75 Volume(const Volume& v) : Geometry(v) {} //!< copy constructor clone() const76 virtual Geometry* clone() const { return new Volume(*this); } //!< virtual copy constructor for Geometry ~Volume()77 virtual ~Volume() {} //!< virtual destructor 78 79 //! format as string asString() const80 virtual string_t asString() const { error("shape_not_handled", words("shape",shape_)); return string_t(); } 81 82 //================================================ 83 // transformations facilities 84 //================================================ 85 //! apply a geometrical transformation on a Volume 86 virtual Volume& transform(const Transformation& t); 87 //! apply a translation on a Volume (vector version) 88 virtual Volume& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 89 //! apply a translation on a Volume (3 reals version) 90 virtual Volume& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 91 //! apply a rotation on a Volume 92 virtual Volume& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 93 //! apply a rotation on a Volume 94 virtual Volume& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 95 real_t angle = 0.); 96 //! apply a rotation on a Volume 97 virtual Volume& rotate3d(real_t dx, real_t dy, real_t angle); 98 //! apply a rotation on a Volume 99 virtual Volume& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 100 //! apply a rotation on a Volume 101 virtual Volume& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 102 //! apply a rotation on a Volume 103 virtual Volume& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 104 //! apply a homothety on a Volume 105 virtual Volume& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 106 //! apply a homothety on a Volume 107 virtual Volume& homothetize(real_t factor); 108 //! apply a point reflection on a Volume 109 virtual Volume& pointReflect(const Point& c = Point(0.,0.,0.)); 110 //! apply a reflection2d on a Volume 111 virtual Volume& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 112 //! apply a reflection2d on a Volume 113 virtual Volume& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 114 //! apply a reflection3d on a Volume 115 virtual Volume& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 116 //! apply a reflection3d on a Volume 117 virtual Volume& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 118 }; 119 120 /*! 121 \class Polyhedron 122 definition of a polyhedral geometry in R^3 123 Generally, a polyhedron is a list of polygonal faces. But data is storages differently to avoid pointer manipulation 124 So, we decide to store : 125 - the list of vertices -> Vector<Point> p_ 126 - the definition of faces as a list of points -> Vector<Vector<number_t> > faces_ 127 it is so that p_[faces_[i][j]] is the j-st vertex of the i-st face of the polyhedron 128 - the number of nodes on each edge -> Vector<Vector<number_t> > n_ 129 it is so that n_[i][j] is the number of nodes on j-st edge [ p_[faces_[i][j]] p_[faces_[i][j+1]] ] of the i-st face 130 of the polyhedron 131 */ 132 class Polyhedron : public Volume 133 { 134 protected: 135 std::vector<Polygon*> faces_; //!< faces of the polyhedron 136 std::vector<Point> p_; //!< vertices of the polyhedron 137 std::vector<number_t> n_; //!< number of nodes on each edge 138 std::vector<real_t> h_; //!< local mesh step on each vertex 139 140 public: 141 //! default constructor 142 Polyhedron(); 143 //! constructor with 1 Parameter 144 Polyhedron(const Parameter& p1); 145 //! constructor with 2 Parameter 146 Polyhedron(const Parameter& p1, const Parameter& p2); 147 148 protected: 149 //@{ 150 //! true constructor functions 151 void buildP(); 152 void build(const std::vector<Parameter>& ps); 153 void buildParam(const Parameter& gp); 154 void buildDefaultParam(ParameterKey key); 155 std::set<ParameterKey> getParamsKeys(); 156 //@} 157 158 public: 159 //! copy constructor 160 Polyhedron(const Polyhedron& ph); 161 //! destructor ~Polyhedron()162 virtual ~Polyhedron() 163 { 164 for (number_t i = 0; i < faces_.size(); ++i) delete faces_[i]; 165 faces_.clear(); 166 } 167 168 //! accessor to vertices p() const169 std::vector<Point> p() const { return p_; } 170 //! accessor to vertex i p(number_t i) const171 Point p(number_t i) const { return p_[i-1]; } 172 //! accessor to faces faces() const173 std::vector<Polygon*> faces() const { return faces_; } 174 //! accessor to number of faces nbFaces() const175 number_t nbFaces() const { return faces_.size(); } 176 177 //! accessor to number of nodes on edge i nOnEdge(number_t i,number_t j) const178 number_t nOnEdge(number_t i, number_t j) const { return faces_[i-1]->n(j); } 179 180 //! format as string 181 virtual string_t asString() const; 182 clone() const183 virtual Geometry* clone() const { return new Polyhedron(*this); } //!< virtual copy constructor 184 withNnodes() const185 bool withNnodes() const { return (h_.size() == 0); } //!< check if Polyhedron is defined only with _nnodes or with _hsteps option 186 187 virtual std::vector<const Point*> boundNodes() const; //!< returns list of points on boundary (const) 188 virtual std::vector<Point*> nodes(); //!< returns list of every point (non const) 189 virtual std::vector<const Point*> nodes() const; //!< returns list of every point (const) 190 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > curves() const; //!< returns list of edges 191 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces nbSides() const192 virtual number_t nbSides() const { return faces_.size(); } //!< returns the number of sides setFaces()193 virtual void setFaces() //! set the faces vector when built 194 {error("not_handled","Polyhedron::setFaces()");} 195 virtual void collect(const string_t& n, std::list<Geometry*>&) const; //!< collect in a list all canonical geometry's with name n 196 197 //! computes the minimal box computeMB()198 virtual void computeMB() { minimalBox = MinimalBox(boundingBox.bounds()); } 199 200 //! access to child Polyhedron object (const) polyhedron() const201 virtual const Polyhedron* polyhedron() const {return this;} 202 //! access to child Polyhedron object polyhedron()203 virtual Polyhedron* polyhedron() {return this;} 204 205 //================================================ 206 // transformations facilities 207 //================================================ 208 //! apply a geometrical transformation on a Polyhedron 209 virtual Polyhedron& transform(const Transformation& t); 210 //! apply a translation on a Polyhedron (vector version) 211 virtual Polyhedron& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 212 //! apply a translation on a Polyhedron (3 reals version) 213 virtual Polyhedron& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 214 //! apply a rotation on a Polyhedron 215 virtual Polyhedron& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 216 //! apply a rotation on a Polyhedron 217 virtual Polyhedron& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 218 real_t angle = 0.); 219 //! apply a rotation on a Polyhedron 220 virtual Polyhedron& rotate3d(real_t dx, real_t dy, real_t angle); 221 //! apply a rotation on a Polyhedron 222 virtual Polyhedron& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 223 //! apply a rotation on a Polyhedron 224 virtual Polyhedron& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 225 //! apply a rotation on a Polyhedron 226 virtual Polyhedron& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 227 //! apply a homothety on a Polyhedron 228 virtual Polyhedron& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 229 //! apply a homothety on a Polyhedron 230 virtual Polyhedron& homothetize(real_t factor); 231 //! apply a point reflection on a Polyhedron 232 virtual Polyhedron& pointReflect(const Point& c = Point(0.,0.,0.)); 233 //! apply a reflection2d on a Polyhedron 234 virtual Polyhedron& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 235 //! apply a reflection2d on a Polyhedron 236 virtual Polyhedron& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 237 //! apply a reflection3d on a Polyhedron 238 virtual Polyhedron& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 239 //! apply a reflection3d on a Polyhedron 240 virtual Polyhedron& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 241 }; 242 243 /*! 244 \class Tetrahedron 245 definition of a tetrahedron geometry in R^3 246 */ 247 class Tetrahedron : public Polyhedron 248 { 249 public: 250 //! default constructor 251 Tetrahedron(); 252 //! constructor with 4 Parameter 253 Tetrahedron(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 254 //! constructor with 5 Parameter 255 Tetrahedron(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 256 //! constructor with 6 Parameter 257 Tetrahedron(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 258 const Parameter& p6); 259 //! constructor with 3 Parameter 260 Tetrahedron(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 261 const Parameter& p6, const Parameter& p7); 262 263 private: 264 //@{ 265 //! true constructor functions 266 void build(const std::vector<Parameter>& ps); 267 void buildParam(const Parameter& gp); 268 void buildDefaultParam(ParameterKey key); 269 std::set<ParameterKey> getParamsKeys(); 270 //@} 271 272 public: 273 //! accessor to number of nodes on edge i n(number_t i) const274 number_t n(number_t i) const { return n_[i-1]; } 275 //! accessor to local steps h() const276 std::vector<real_t> h() const {return h_;} 277 //! accessor to local step on vertex i (read only) h(number_t i) const278 real_t h(number_t i) const { return h_[i-1];} 279 280 //! format as string 281 virtual string_t asString() const; 282 clone() const283 virtual Geometry* clone() const { return new Tetrahedron(*this); } //!< virtual copy constructor 284 285 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > curves() const; //!< returns list of edges 286 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces nbSides() const287 virtual number_t nbSides() const { return 4; } //!< returns the number of sides 288 virtual void setFaces(); //!< set the faces vector when built 289 real_t measure() const; 290 291 //! computes the minimal box computeMB()292 virtual void computeMB() { minimalBox=MinimalBox(p_[0],p_[1],p_[2],p_[3]); } 293 294 //! access to child Tetrahedron object (const) tetrahedron() const295 virtual const Tetrahedron* tetrahedron() const {return this;} 296 //! access to child Tetrahedron object tetrahedron()297 virtual Tetrahedron* tetrahedron() {return this;} 298 299 //================================================ 300 // transformations facilities 301 //================================================ 302 //! apply a geometrical transformation on a Tetrahedron 303 virtual Tetrahedron& transform(const Transformation& t); 304 //! apply a translation on a Tetrahedron (vector version) 305 virtual Tetrahedron& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 306 //! apply a translation on a Tetrahedron (3 reals version) 307 virtual Tetrahedron& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 308 //! apply a rotation on a Tetrahedron 309 virtual Tetrahedron& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 310 //! apply a rotation on a Tetrahedron 311 virtual Tetrahedron& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 312 real_t angle = 0.); 313 //! apply a rotation on a Tetrahedron 314 virtual Tetrahedron& rotate3d(real_t dx, real_t dy, real_t angle); 315 //! apply a rotation on a Tetrahedron 316 virtual Tetrahedron& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 317 //! apply a rotation on a Tetrahedron 318 virtual Tetrahedron& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 319 //! apply a rotation on a Tetrahedron 320 virtual Tetrahedron& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 321 //! apply a homothety on a Tetrahedron 322 virtual Tetrahedron& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 323 //! apply a homothety on a Tetrahedron 324 virtual Tetrahedron& homothetize(real_t factor); 325 //! apply a point reflection on a Tetrahedron 326 virtual Tetrahedron& pointReflect(const Point& c = Point(0.,0.,0.)); 327 //! apply a reflection2d on a Tetrahedron 328 virtual Tetrahedron& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 329 //! apply a reflection2d on a Tetrahedron 330 virtual Tetrahedron& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 331 //! apply a reflection3d on a Tetrahedron 332 virtual Tetrahedron& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 333 //! apply a reflection3d on a Tetrahedron 334 virtual Tetrahedron& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 335 }; 336 337 /*! 338 \class Hexahedron 339 definition of a hexahedron geometry in R^3 340 */ 341 class Hexahedron : public Polyhedron 342 { 343 public: 344 //! default constructor 345 Hexahedron(); 346 //! constructor with 4 Parameter 347 Hexahedron(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 348 const Parameter& p6, const Parameter& p7, const Parameter& p8); 349 //! constructor with 5 Parameter 350 Hexahedron(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 351 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9); 352 //! constructor with 6 Parameter 353 Hexahedron(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 354 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9, const Parameter& p10); 355 //! constructor with 3 Parameter 356 Hexahedron(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 357 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9, const Parameter& p10, 358 const Parameter& p11); 359 360 protected: 361 //@{ 362 //! true constructor functions 363 void build(const std::vector<Parameter>& ps); 364 void buildParam(const Parameter& gp); 365 void buildDefaultParam(ParameterKey key); 366 std::set<ParameterKey> getParamsKeys(); 367 //@} 368 369 public: 370 //! accessor to number of nodes on edge i n(number_t i) const371 number_t n(number_t i) const { return n_[i-1]; } 372 //! accessor to local steps h() const373 std::vector<real_t> h() const {return h_;} 374 //! accessor to local step on vertex i (read only) h(number_t i) const375 real_t h(number_t i) const { return h_[i-1];} 376 377 //! format as string 378 virtual string_t asString() const; 379 clone() const380 virtual Geometry* clone() const { return new Hexahedron(*this); } //!< virtual copy constructor 381 382 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > curves() const; //!< returns list of edges 383 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces nbSides() const384 virtual number_t nbSides() const { return 8; } //!< returns the number of sides 385 virtual void setFaces(); //!< set the faces vector when built 386 387 //! access to child Hexahedron object (const) hexahedron() const388 virtual const Hexahedron* hexahedron() const {return this;} 389 //! access to child Hexahedron object hexahedron()390 virtual Hexahedron* hexahedron() {return this;} 391 392 //================================================ 393 // transformations facilities 394 //================================================ 395 //! apply a geometrical transformation on a Hexahedron 396 virtual Hexahedron& transform(const Transformation& t); 397 //! apply a translation on a Hexahedron (vector version) 398 virtual Hexahedron& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 399 //! apply a translation on a Hexahedron (3 reals version) 400 virtual Hexahedron& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 401 //! apply a rotation on a Hexahedron 402 virtual Hexahedron& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 403 //! apply a rotation on a Hexahedron 404 virtual Hexahedron& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 405 real_t angle = 0.); 406 //! apply a rotation on a Hexahedron 407 virtual Hexahedron& rotate3d(real_t dx, real_t dy, real_t angle); 408 //! apply a rotation on a Hexahedron 409 virtual Hexahedron& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 410 //! apply a rotation on a Hexahedron 411 virtual Hexahedron& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 412 //! apply a rotation on a Hexahedron 413 virtual Hexahedron& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 414 //! apply a homothety on a Hexahedron 415 virtual Hexahedron& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 416 //! apply a homothety on a Hexahedron 417 virtual Hexahedron& homothetize(real_t factor); 418 //! apply a point reflection on a Hexahedron 419 virtual Hexahedron& pointReflect(const Point& c = Point(0.,0.,0.)); 420 //! apply a reflection2d on a Hexahedron 421 virtual Hexahedron& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 422 //! apply a reflection2d on a Hexahedron 423 virtual Hexahedron& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 424 //! apply a reflection3d on a Hexahedron 425 virtual Hexahedron& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 426 //! apply a reflection3d on a Hexahedron 427 virtual Hexahedron& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 428 }; 429 430 /*! 431 \class Parallelepiped 432 definition of a parallelepiped geometry in R^3 433 */ 434 class Parallelepiped : public Hexahedron 435 { 436 public: 437 //! default constructor 438 Parallelepiped(); 439 //! constructor with 4 Parameter 440 Parallelepiped(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 441 //! constructor with 5 Parameter 442 Parallelepiped(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 443 //! constructor with 6 Parameter 444 Parallelepiped(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 445 const Parameter& p6); 446 //! constructor with 7 Parameter 447 Parallelepiped(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 448 const Parameter& p6, const Parameter& p7); 449 450 protected: 451 //@{ 452 //! true constructor functions 453 void build(const std::vector<Parameter>& ps); 454 void buildParam(const Parameter& gp); 455 void buildDefaultParam(ParameterKey key); 456 std::set<ParameterKey> getParamsKeys(); 457 //@} 458 459 public: 460 //! returns number of nodes on edges 1, 3, 5 and 7 n1() const461 number_t n1() const {return n(1);} 462 //! returns number of nodes on edges 2, 4, 6 and 8 n2() const463 number_t n2() const {return n(2);} 464 //! retusn number of nodes on edges 9, 10, 11 and 12 n3() const465 number_t n3() const {return n(9);} 466 467 //! format as string 468 virtual string_t asString() const; 469 clone() const470 virtual Geometry* clone() const { return new Parallelepiped(*this); } //!< virtual copy constructor 471 472 virtual void setFaces(); //!< set the faces vector when built 473 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces 474 real_t measure() const; 475 476 //! computes the minimal box computeMB()477 virtual void computeMB() { minimalBox= MinimalBox(p_[0],p_[1],p_[3],p_[4]); } 478 479 //! access to child Parallelepiped object (const) parallelepiped() const480 virtual const Parallelepiped* parallelepiped() const {return this;} 481 //! access to child Parallelepiped object parallelepiped()482 virtual Parallelepiped* parallelepiped() {return this;} 483 484 //================================================ 485 // transformations facilities 486 //================================================ 487 //! apply a geometrical transformation on a Parallelepiped 488 virtual Parallelepiped& transform(const Transformation& t); 489 //! apply a translation on a Parallelepiped (vector version) 490 virtual Parallelepiped& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 491 //! apply a translation on a Parallelepiped (3 reals version) 492 virtual Parallelepiped& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 493 //! apply a rotation on a Parallelepiped 494 virtual Parallelepiped& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 495 //! apply a rotation on a Parallelepiped 496 virtual Parallelepiped& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 497 real_t angle = 0.); 498 //! apply a rotation on a Parallelepiped 499 virtual Parallelepiped& rotate3d(real_t dx, real_t dy, real_t angle); 500 //! apply a rotation on a Parallelepiped 501 virtual Parallelepiped& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 502 //! apply a rotation on a Parallelepiped 503 virtual Parallelepiped& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 504 //! apply a rotation on a Parallelepiped 505 virtual Parallelepiped& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 506 //! apply a homothety on a Parallelepiped 507 virtual Parallelepiped& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 508 //! apply a homothety on a Parallelepiped 509 virtual Parallelepiped& homothetize(real_t factor); 510 //! apply a point reflection on a Parallelepiped 511 virtual Parallelepiped& pointReflect(const Point& c = Point(0.,0.,0.)); 512 //! apply a reflection2d on a Parallelepiped 513 virtual Parallelepiped& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 514 //! apply a reflection2d on a Parallelepiped 515 virtual Parallelepiped& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 516 //! apply a reflection3d on a Parallelepiped 517 virtual Parallelepiped& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 518 //! apply a reflection3d on a Parallelepiped 519 virtual Parallelepiped& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 520 }; 521 522 /*! 523 \class Cuboid 524 definition of a cuboid (=rectangular parallelepiped) geometry in R^3 525 */ 526 class Cuboid : public Parallelepiped 527 { 528 protected: 529 // initialized when rectangle defined with center or origin keys 530 Point center_, origin_; 531 // true when corresponding key group is given 532 bool isCenter_, isOrigin_; 533 // initialized when rectangle defined with center or origin keys 534 real_t xlength_, ylength_, zlength_; 535 private: 536 // initialized when rectangle defined with xmin, xmax, ymin, ymax keys 537 real_t xmin_, xmax_, ymin_, ymax_, zmin_, zmax_; 538 // true when corresponding key group is given 539 bool isBounds_; 540 541 public: 542 //! default constructor 543 Cuboid(); 544 //! constructor with 4 Parameter 545 Cuboid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 546 //! constructor with 5 Parameter 547 Cuboid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 548 //! constructor with 6 Parameter 549 Cuboid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 550 const Parameter& p6); 551 //! constructor with 7 Parameter 552 Cuboid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 553 const Parameter& p6, const Parameter& p7); 554 //! constructor with 8 Parameter 555 Cuboid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 556 const Parameter& p6, const Parameter& p7, const Parameter& p8); 557 //! constructor with 9 Parameter 558 Cuboid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 559 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9); 560 561 protected: 562 //@{ 563 //! true constructor functions 564 void buildP(); 565 void build(const std::vector<Parameter>& ps); 566 void buildParam(const Parameter& gp); 567 void buildDefaultParam(ParameterKey key); 568 std::set<ParameterKey> getParamsKeys(); 569 //@} 570 571 public: 572 //! copy constructor 573 Cuboid(const Cuboid& c); 574 //! returns number of nodes on edges 1, 3, 5 and 7 nx() const575 number_t nx() const {return n(1);} 576 //! returns number of nodes on edges 2, 4, 6 and 8 ny() const577 number_t ny() const {return n(2);} 578 //! retusn number of nodes on edges 9, 10, 11 and 12 nz() const579 number_t nz() const {return n(9);} 580 581 //! format as string 582 virtual string_t asString() const; 583 clone() const584 virtual Geometry* clone() const { return new Cuboid(*this); } //!< virtual copy constructor 585 586 virtual void setFaces(); //!< set the faces vector when built 587 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces measure() const588 real_t measure() const { return xlength_*ylength_*zlength_; } 589 590 //! computes the minimal box computeMB()591 virtual void computeMB() { minimalBox= MinimalBox(p_[0],p_[1],p_[3],p_[4]); } 592 593 //! access to child Cuboid object (const) cuboid() const594 virtual const Cuboid* cuboid() const {return this;} 595 //! access to child Cuboid object cuboid()596 virtual Cuboid* cuboid() {return this;} 597 598 //================================================ 599 // transformations facilities 600 //================================================ 601 //! apply a geometrical transformation on a Cuboid 602 virtual Cuboid& transform(const Transformation& t); 603 //! apply a translation on a Cuboid (vector version) 604 virtual Cuboid& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 605 //! apply a translation on a Cuboid (3 reals version) 606 virtual Cuboid& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 607 //! apply a rotation on a Cuboid 608 virtual Cuboid& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 609 //! apply a rotation on a Cuboid 610 virtual Cuboid& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 611 real_t angle = 0.); 612 //! apply a rotation on a Cuboid 613 virtual Cuboid& rotate3d(real_t dx, real_t dy, real_t angle); 614 //! apply a rotation on a Cuboid 615 virtual Cuboid& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 616 //! apply a rotation on a Cuboid 617 virtual Cuboid& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 618 //! apply a rotation on a Cuboid 619 virtual Cuboid& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 620 //! apply a homothety on a Cuboid 621 virtual Cuboid& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 622 //! apply a homothety on a Cuboid 623 virtual Cuboid& homothetize(real_t factor); 624 //! apply a point reflection on a Cuboid 625 virtual Cuboid& pointReflect(const Point& c = Point(0.,0.,0.)); 626 //! apply a reflection2d on a Cuboid 627 virtual Cuboid& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 628 //! apply a reflection2d on a Cuboid 629 virtual Cuboid& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 630 //! apply a reflection3d on a Cuboid 631 virtual Cuboid& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 632 //! apply a reflection3d on a Cuboid 633 virtual Cuboid& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 634 }; 635 636 /*! 637 \class Cube 638 A cube is defined by its center and the length of its edges. 639 */ 640 class Cube : public Cuboid 641 { 642 private: 643 dimen_t nboctants_; //!< number of octants to be filled in the 3D space 644 645 public: 646 //! default constructor 647 Cube(); 648 //! constructor with 2 Parameter 649 Cube(const Parameter& p1, const Parameter& p2); 650 //! constructor with 3 Parameter 651 Cube(const Parameter& p1, const Parameter& p2, const Parameter& p3); 652 //! constructor with 4 Parameter 653 Cube(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 654 //! constructor with 5 Parameter 655 Cube(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 656 //! constructor with 6 Parameter 657 Cube(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 658 const Parameter& p6); 659 //! constructor with 7 Parameter 660 Cube(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 661 const Parameter& p6, const Parameter& p7); 662 663 private: 664 //@{ 665 //! true constructor functions 666 void buildP(); 667 void build(const std::vector<Parameter>& ps); 668 void buildParam(const Parameter& gp); 669 void buildDefaultParam(ParameterKey key); 670 std::set<ParameterKey> getParamsKeys(); 671 //@} 672 673 public: 674 //! copy constructor 675 Cube(const Cube& c); 676 //! format as string 677 virtual string_t asString() const; 678 679 // access functions to data members center() const680 Point center() const { return center_; } //!< returns center edgeLen() const681 real_t edgeLen() const { return xlength_; } //!< returns edge length rotations() const682 std::vector<std::pair<real_t, dimen_t> > rotations() const //! returns rotations 683 { return trihedralOrientation(p_[0], p_[1], p_[3], p_[4]); } 684 nbOctants() const685 virtual dimen_t nbOctants() const { return nboctants_; } //!< returns number of octants 686 virtual number_t nbSubdiv() const; //!< returns number of subdivision 687 clone() const688 virtual Geometry* clone() const { return new Cube(*this); } //!< virtual copy constructor 689 690 virtual void setFaces(); //!< set the faces vector when built 691 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces measure() const692 real_t measure() const { return xlength_*ylength_*zlength_/8.*nboctants_; } 693 694 //! access to child Cube object (const) cube() const695 virtual const Cube* cube() const {return this;} 696 //! access to child Cube object cube()697 virtual Cube* cube() {return this;} 698 699 //================================================ 700 // transformations facilities 701 //================================================ 702 //! apply a geometrical transformation on a Cube 703 virtual Cube& transform(const Transformation& t); 704 //! apply a translation on a Cube (vector version) 705 virtual Cube& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 706 //! apply a translation on a Cube (3 reals version) 707 virtual Cube& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 708 //! apply a rotation on a Cube 709 virtual Cube& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 710 //! apply a rotation on a Cube 711 virtual Cube& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 712 real_t angle = 0.); 713 //! apply a rotation on a Cube 714 virtual Cube& rotate3d(real_t dx, real_t dy, real_t angle); 715 //! apply a rotation on a Cube 716 virtual Cube& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 717 //! apply a rotation on a Cube 718 virtual Cube& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 719 //! apply a rotation on a Cube 720 virtual Cube& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 721 //! apply a homothety on a Cube 722 virtual Cube& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 723 //! apply a homothety on a Cube 724 virtual Cube& homothetize(real_t factor); 725 //! apply a point reflection on a Cube 726 virtual Cube& pointReflect(const Point& c = Point(0.,0.,0.)); 727 //! apply a reflection2d on a Cube 728 virtual Cube& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 729 //! apply a reflection2d on a Cube 730 virtual Cube& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 731 //! apply a reflection3d on a Cube 732 virtual Cube& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 733 //! apply a reflection3d on a Cube 734 virtual Cube& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 735 }; 736 737 /*! 738 \class Ellipsoid 739 definition of an ellipsoidal geometry in R^3 (volume) 740 */ 741 class Ellipsoid : public Volume 742 { 743 protected: 744 Point center_; //!< center of the ellipsoid 745 Point p1_; //!< first apogee of the ellipsoid 746 Point p2_; //!< second apogee of the ellipsoid 747 Point p3_; //!< first perigee of the ellipsoid 748 Point p4_; //!< second perigee of the ellipsoid 749 Point p5_; //!< third perigee of the ellipsoid 750 Point p6_; //!< third apogee of the ellipsoid 751 real_t xlength_, ylength_, zlength_; 752 bool isAxis_; 753 754 number_t n1_; //!< number of nodes on edge [p1_ p2_] 755 number_t n2_; //!< number of nodes on edge [p2_ p3_] 756 number_t n3_; //!< number of nodes on edge [p3_ p4_] 757 number_t n4_; //!< number of nodes on edge [p4_ p1_] 758 number_t n5_; //!< number of nodes on edge [p1_ p6_] 759 number_t n6_; //!< number of nodes on edge [p6_ p3_] 760 number_t n7_; //!< number of nodes on edge [p3_ p5_] 761 number_t n8_; //!< number of nodes on edge [p5_ p1_] 762 number_t n9_; //!< number of nodes on edge [p2_ p6_] 763 number_t n10_; //!< number of nodes on edge [p6_ p4_] 764 number_t n11_; //!< number of nodes on edge [p4_ p5_] 765 number_t n12_; //!< number of nodes on edge [p5_ p2_] 766 std::vector<real_t> h_; //!< local mesh step on each vertex of the ellipsoid 767 768 dimen_t nboctants_; //!< number of octants to be filled in the 3D space 769 dimen_t type_; //!< indicator to fit curved boundaries (default) or not which gives flat (or plane) boundaries 770 771 public: 772 //! default constructor 773 Ellipsoid(); 774 //! constructor with 4 Parameter 775 Ellipsoid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 776 //! constructor with 5 Parameter 777 Ellipsoid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 778 //! constructor with 6 Parameter 779 Ellipsoid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 780 const Parameter& p6); 781 //! constructor with 7 Parameter 782 Ellipsoid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 783 const Parameter& p6, const Parameter& p7); 784 //! constructor with 8 Parameter 785 Ellipsoid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 786 const Parameter& p6, const Parameter& p7, const Parameter& p8); 787 //! constructor with 9 Parameter 788 Ellipsoid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 789 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9); 790 791 protected: 792 //@{ 793 //! true constructor functions 794 void buildP(); 795 void build(const std::vector<Parameter>& ps); 796 void buildParam(const Parameter& gp); 797 void buildDefaultParam(ParameterKey key); 798 std::set<ParameterKey> getParamsKeys(); 799 //@} 800 801 public: 802 //! copy constructor 803 Ellipsoid(const Ellipsoid& e); 804 805 //@{ 806 //! accessor to point center() const807 Point center() const { return center_;} p1() const808 Point p1() const { return p1_;} p2() const809 Point p2() const { return p2_;} p3() const810 Point p3() const { return p3_;} p4() const811 Point p4() const { return p4_;} p5() const812 Point p5() const { return p5_;} p6() const813 Point p6() const { return p6_;} 814 //@} 815 816 //@{ 817 //! accessor to number of nodes on edge n1() const818 number_t n1() const {return n1_;} n2() const819 number_t n2() const {return n2_;} n3() const820 number_t n3() const {return n3_;} n4() const821 number_t n4() const {return n4_;} n5() const822 number_t n5() const {return n5_;} n6() const823 number_t n6() const {return n6_;} n7() const824 number_t n7() const {return n7_;} n8() const825 number_t n8() const {return n8_;} n9() const826 number_t n9() const {return n9_;} n10() const827 number_t n10() const {return n10_;} n11() const828 number_t n11() const {return n11_;} n12() const829 number_t n12() const {return n12_;} 830 //@} 831 832 //! accessor to local steps h() const833 std::vector<real_t> h() const {return h_;} 834 //! accessor to local step on vertex i (read only) h(number_t i) const835 real_t h(number_t i) const { return h_[i-1];} 836 length1() const837 real_t length1() const { return xlength_; } //!< return first axis length length2() const838 real_t length2() const { return ylength_; } //!< return second axis length length3() const839 real_t length3() const { return zlength_; } //!< return third axis length rotations() const840 std::vector<std::pair<real_t, dimen_t> > rotations() const //! returns rotations 841 { return trihedralOrientation(center_, p1_, p2_, p6_); } nbOctants() const842 virtual dimen_t nbOctants() const { return nboctants_; } //!< returns number of octants 843 virtual number_t nbSubdiv() const; //!< returns number of subdivisions type() const844 virtual dimen_t type() const { return type_; } //!< return type of subdivision 845 846 //! format as string 847 virtual string_t asString() const; 848 clone() const849 virtual Geometry* clone() const { return new Ellipsoid(*this); } //!< virtual copy constructor 850 withNnodes() const851 bool withNnodes() const { return (h_.size() == 0); } //!< check if Ellipsoid is defined only with _nnodes or with _hsteps option 852 853 virtual std::vector<const Point*> boundNodes() const; //!< returns list of points on boundary (const) 854 virtual std::vector<Point*> nodes(); //!< returns list of every point (non const) 855 virtual std::vector<const Point*> nodes() const; //!< returns list of every point (const) 856 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > curves() const; //!< returns list of edges 857 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces nbSides() const858 virtual number_t nbSides() const { return 8; } //!< returns the number of sides 859 real_t measure() const; 860 861 //! computes the minimal box computeMB()862 virtual void computeMB() 863 { minimalBox= MinimalBox(4.*center_-p1_-p2_-p6_, 2.*center_+p1_-p2_-p6_, 2.*center_+p2_-p1_-p6_, 2.*center_+p6_-p1_-p2_); } 864 865 //! access to child Ellipsoid object (const) ellipsoid() const866 virtual const Ellipsoid* ellipsoid() const {return this;} 867 //! access to child Ellipsoid object ellipsoid()868 virtual Ellipsoid* ellipsoid() {return this;} 869 870 //================================================ 871 // transformations facilities 872 //================================================ 873 //! apply a geometrical transformation on a Ellipsoid 874 virtual Ellipsoid& transform(const Transformation& t); 875 //! apply a translation on a Ellipsoid (vector version) 876 virtual Ellipsoid& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 877 //! apply a translation on a Ellipsoid (3 reals version) 878 virtual Ellipsoid& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 879 //! apply a rotation on a Ellipsoid 880 virtual Ellipsoid& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 881 //! apply a rotation on a Ellipsoid 882 virtual Ellipsoid& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 883 real_t angle = 0.); 884 //! apply a rotation on a Ellipsoid 885 virtual Ellipsoid& rotate3d(real_t dx, real_t dy, real_t angle); 886 //! apply a rotation on a Ellipsoid 887 virtual Ellipsoid& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 888 //! apply a rotation on a Ellipsoid 889 virtual Ellipsoid& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 890 //! apply a rotation on a Ellipsoid 891 virtual Ellipsoid& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 892 //! apply a homothety on a Ellipsoid 893 virtual Ellipsoid& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 894 //! apply a homothety on a Ellipsoid 895 virtual Ellipsoid& homothetize(real_t factor); 896 //! apply a point reflection on a Ellipsoid 897 virtual Ellipsoid& pointReflect(const Point& c = Point(0.,0.,0.)); 898 //! apply a reflection2d on a Ellipsoid 899 virtual Ellipsoid& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 900 //! apply a reflection2d on a Ellipsoid 901 virtual Ellipsoid& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 902 //! apply a reflection3d on a Ellipsoid 903 virtual Ellipsoid& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 904 //! apply a reflection3d on a Ellipsoid 905 virtual Ellipsoid& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 906 }; 907 908 /*! 909 \class Ball 910 A sphere is defined by its center and radius. 911 Rotations may be additionnaly defined to orient the axes of the ball. This is useful for the subdivision algorithm 912 when only a portion of the ball is considered. 913 */ 914 class Ball : public Ellipsoid 915 { 916 public: 917 //! default constructor 918 Ball(); 919 //! constructor with 2 Parameter 920 Ball(const Parameter& p1, const Parameter& p2); 921 //! constructor with 3 Parameter 922 Ball(const Parameter& p1, const Parameter& p2, const Parameter& p3); 923 //! constructor with 4 Parameter 924 Ball(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 925 //! constructor with 5 Parameter 926 Ball(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 927 //! constructor with 6 Parameter 928 Ball(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 929 const Parameter& p6); 930 //! constructor with 7 Parameter 931 Ball(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 932 const Parameter& p6, const Parameter& p7); 933 //! constructor with 8 Parameter 934 Ball(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 935 const Parameter& p6, const Parameter& p7, const Parameter& p8); 936 //! constructor with 9 Parameter 937 Ball(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 938 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9); 939 940 protected: 941 //@{ 942 //! true constructor functions 943 void build(const std::vector<Parameter>& ps); 944 void buildParam(const Parameter& gp); 945 void buildDefaultParam(ParameterKey key); 946 std::set<ParameterKey> getParamsKeys(); 947 //@} 948 949 public: 950 //! copy constructor 951 Ball(const Ball& b); 952 //! format as string : "Ball (center=(.,.,.), radius = R)" 953 virtual string_t asString() const; 954 955 // access functions to data members radius() const956 real_t radius() const { return xlength_/2.; } //!< returns radius 957 clone() const958 virtual Geometry* clone() const { return new Ball(*this); } //!< virtual copy constructor 959 960 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > curves() const; //!< returns list of edges 961 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces 962 963 //! access to child Ball object (const) ball() const964 virtual const Ball* ball() const {return this;} 965 //! access to child Ball object ball()966 virtual Ball* ball() {return this;} 967 968 //================================================ 969 // transformations facilities 970 //================================================ 971 //! apply a geometrical transformation on a Ball 972 virtual Ball& transform(const Transformation& t); 973 //! apply a translation on a Ball (vector version) 974 virtual Ball& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 975 //! apply a translation on a Ball (3 reals version) 976 virtual Ball& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 977 //! apply a rotation on a Ball 978 virtual Ball& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 979 //! apply a rotation on a Ball 980 virtual Ball& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 981 real_t angle = 0.); 982 //! apply a rotation on a Ball 983 virtual Ball& rotate3d(real_t dx, real_t dy, real_t angle); 984 //! apply a rotation on a Ball 985 virtual Ball& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 986 //! apply a rotation on a Ball 987 virtual Ball& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 988 //! apply a rotation on a Ball 989 virtual Ball& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 990 //! apply a homothety on a Ball 991 virtual Ball& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 992 //! apply a homothety on a Ball 993 virtual Ball& homothetize(real_t factor); 994 //! apply a point reflection on a Ball 995 virtual Ball& pointReflect(const Point& c = Point(0.,0.,0.)); 996 //! apply a reflection2d on a Ball 997 virtual Ball& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 998 //! apply a reflection2d on a Ball 999 virtual Ball& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 1000 //! apply a reflection3d on a Ball 1001 virtual Ball& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 1002 //! apply a reflection3d on a Ball 1003 virtual Ball& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 1004 }; 1005 1006 typedef Ball Sphere; 1007 1008 /*! 1009 \class Trunk 1010 A Trunk is a volume defined by a cylinder or a trunk of cone. A cylinder is a trunk of a cylinder !!! 1011 To define it, we need a basis, a translation and a homothety to build the other basis. 1012 To make it more simple, we will need a basis, the first point of the other basis (determining the translation 1013 and the center of the homothety), and a scale factor. This "first point" of a basis is defined as basis.p(1) : it is 1014 the first vertex for a polygon, but the center for an ellipse or a disk 1015 */ 1016 class Trunk : public Volume 1017 { 1018 protected: 1019 //! first surfacic basis 1020 Surface * basis_; 1021 //! scale factor 1022 real_t scale_; 1023 //! points used to define the geometry 1024 std::vector<Point> p_; 1025 //! number of nodes on edges 1026 std::vector<number_t> n_; 1027 //! local mesh step on each vertex of the cylinder 1028 std::vector<real_t> h_; 1029 Point origin_, center1_, p1_, p2_; 1030 bool isElliptical_, isN_; 1031 1032 public: 1033 //! default constructor 1034 Trunk(real_t scale=1, bool defineBasisAndP=true); 1035 //! constructor with 3 Parameter 1036 Trunk(const Parameter& p1, const Parameter& p2, const Parameter& p3); 1037 //! constructor with 4 Parameter 1038 Trunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 1039 //! constructor with 5 Parameter 1040 Trunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 1041 //! constructor with 6 Parameter 1042 Trunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1043 const Parameter& p6); 1044 //! constructor with 7 Parameter 1045 Trunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1046 const Parameter& p6, const Parameter& p7); 1047 //! constructor with 8 Parameter 1048 Trunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1049 const Parameter& p6, const Parameter& p7, const Parameter& p8); 1050 1051 protected: 1052 //@{ 1053 //! true constructor functions 1054 void buildPAndBasis(); 1055 void build(const std::vector<Parameter>& ps); 1056 void buildParam(const Parameter& gp); 1057 void buildDefaultParam(ParameterKey key); 1058 std::set<ParameterKey> getParamsKeys(); 1059 //@} 1060 1061 public: 1062 //! copy constructor 1063 Trunk(const Trunk& t); 1064 //! destructor ~Trunk()1065 virtual ~Trunk() { if (basis_ != 0) { delete basis_; } } 1066 1067 //! accessor to points p() const1068 std::vector<Point> p() const { return p_; } 1069 //! accessor to point i p(number_t i) const1070 Point p(number_t i) const { return p_[i-1]; } 1071 //! accessor to number of nodes (read only) n() const1072 std::vector<number_t> n() const { return n_; } 1073 //! accessor to number of nodes on edge i (read only) n(number_t i) const1074 number_t n(number_t i) const { return n_[i-1]; } 1075 //! accessor to local steps h() const1076 std::vector<real_t> h() const {return h_;} 1077 //! accessor to local step on vertex i (read only) h(number_t i) const1078 real_t h(number_t i) const { return h_[i-1];} 1079 //! accessor to basis of trunk basis() const1080 Surface* basis() const { return basis_; } 1081 //! accessor to scale factor of trunk scale() const1082 real_t scale() const { return scale_; } 1083 //! accessor to origin_ of trunk origin() const1084 Point origin() const { return origin_; } 1085 //! accessor to origin_ of trunk center1() const1086 Point center1() const { return center1_; } 1087 //! accessor to origin_ of trunk center2() const1088 Point center2() const { return origin_; } 1089 //! accessor to origin_ of trunk p1() const1090 Point p1() const { return p1_; } 1091 //! accessor to origin_ of trunk p2() const1092 Point p2() const { return p2_; } 1093 1094 //! format as string 1095 virtual string_t asString() const; 1096 clone() const1097 virtual Geometry* clone() const { return new Trunk(*this); } //!< virtual copy constructor 1098 withNnodes() const1099 bool withNnodes() const { return (h_.size() == 0); } //!< check if Trunk is defined only with _nnodes or with _hsteps option 1100 1101 virtual std::vector<const Point*> boundNodes() const; //!< returns list of points on boundary (const) 1102 virtual std::vector<Point*> nodes(); //!< return list of every point (non const) 1103 virtual std::vector<const Point*> nodes() const; //!< returns list of every point (const) 1104 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > curves() const; //!< returns list of curves (const) 1105 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces (const) nbSides() const1106 virtual number_t nbSides() const { return basis_->nbSides()+2; } //!< returns the number of sides 1107 real_t measure() const; 1108 computeMB()1109 virtual void computeMB() 1110 { 1111 minimalBox= MinimalBox(basis_->minimalBox.boundPt(1), 1112 basis_->minimalBox.boundPt(2), 1113 basis_->minimalBox.boundPt(3), 1114 basis_->minimalBox.boundPt(1)+origin_-basis_->p(1)); 1115 } 1116 1117 //! access to child Trunk object (const) trunk() const1118 virtual const Trunk* trunk() const {return this;} 1119 //! access to child Trunk object trunk()1120 virtual Trunk* trunk() {return this;} 1121 1122 //================================================ 1123 // transformations facilities 1124 //================================================ 1125 //! apply a geometrical transformation on a Trunk 1126 virtual Trunk& transform(const Transformation& t); 1127 //! apply a translation on a Trunk (vector version) 1128 virtual Trunk& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 1129 //! apply a translation on a Trunk (3 reals version) 1130 virtual Trunk& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 1131 //! apply a rotation on a Trunk 1132 virtual Trunk& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 1133 //! apply a rotation on a Trunk 1134 virtual Trunk& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 1135 real_t angle = 0.); 1136 //! apply a rotation on a Trunk 1137 virtual Trunk& rotate3d(real_t dx, real_t dy, real_t angle); 1138 //! apply a rotation on a Trunk 1139 virtual Trunk& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 1140 //! apply a rotation on a Trunk 1141 virtual Trunk& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 1142 //! apply a rotation on a Trunk 1143 virtual Trunk& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 1144 //! apply a homothety on a Trunk 1145 virtual Trunk& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 1146 //! apply a homothety on a Trunk 1147 virtual Trunk& homothetize(real_t factor); 1148 //! apply a point reflection on a Trunk 1149 virtual Trunk& pointReflect(const Point& c = Point(0.,0.,0.)); 1150 //! apply a reflection2d on a Trunk 1151 virtual Trunk& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 1152 //! apply a reflection2d on a Trunk 1153 virtual Trunk& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 1154 //! apply a reflection3d on a Trunk 1155 virtual Trunk& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 1156 //! apply a reflection3d on a Trunk 1157 virtual Trunk& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 1158 }; 1159 1160 /*! 1161 \class Cylinder 1162 A cylinder is a volume defined by a section (the basis) and a direction vector 1163 The direction vector is not necessarily orthogonal to the basis, but both bases are necessarily parallel 1164 A Cylinder is a Trunk with scale factor equal to 1 !!! 1165 */ 1166 class Cylinder : public Trunk 1167 { 1168 protected: 1169 //! direction vector 1170 Point dir_; 1171 1172 public: 1173 //! default constructor 1174 Cylinder(bool defineBasisAndP=true); 1175 //! default constructor with basis and direction 1176 Cylinder(const Surface& basis, const std::vector<real_t>& direction); 1177 //! constructor with 2 Parameter 1178 Cylinder(const Parameter& p1, const Parameter& p2); 1179 //! constructor with 3 Parameter 1180 Cylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3); 1181 //! constructor with 4 Parameter 1182 Cylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 1183 //! constructor with 5 Parameter 1184 Cylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 1185 //! constructor with 6 Parameter 1186 Cylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1187 const Parameter& p6); 1188 //! constructor with 7 Parameter 1189 Cylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1190 const Parameter& p6, const Parameter& p7); 1191 1192 protected: 1193 //@{ 1194 //! true constructor functions 1195 void build(const std::vector<Parameter>& ps); 1196 void buildParam(const Parameter& gp); 1197 void buildDefaultParam(ParameterKey key); 1198 std::set<ParameterKey> getParamsKeys(); 1199 //@} 1200 1201 public: 1202 //! copy constructor 1203 Cylinder(const Cylinder& c); 1204 1205 //! accessor to direction vector dir() const1206 Point dir() const { return dir_; } 1207 1208 //! format as string 1209 virtual string_t asString() const; 1210 clone() const1211 virtual Geometry* clone() const { return new Cylinder(*this); } //!< virtual copy constructor 1212 1213 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces (const) 1214 computeMB()1215 virtual void computeMB() 1216 { 1217 minimalBox= MinimalBox(basis_->minimalBox.boundPt(1), 1218 basis_->minimalBox.boundPt(2), 1219 basis_->minimalBox.boundPt(3), 1220 basis_->minimalBox.boundPt(1)+dir_); 1221 } 1222 1223 //! access to child Cylinder object (const) cylinder() const1224 virtual const Cylinder* cylinder() const {return this;} 1225 //! access to child Cylinder2d object cylinder()1226 virtual Cylinder* cylinder() {return this;} 1227 1228 //================================================ 1229 // transformations facilities 1230 //================================================ 1231 //! apply a geometrical transformation on a Cylinder 1232 virtual Cylinder& transform(const Transformation& t); 1233 //! apply a translation on a Cylinder (vector version) 1234 virtual Cylinder& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 1235 //! apply a translation on a Cylinder (3 reals version) 1236 virtual Cylinder& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 1237 //! apply a rotation on a Cylinder 1238 virtual Cylinder& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 1239 //! apply a rotation on a Cylinder 1240 virtual Cylinder& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 1241 real_t angle = 0.); 1242 //! apply a rotation on a Cylinder 1243 virtual Cylinder& rotate3d(real_t dx, real_t dy, real_t angle); 1244 //! apply a rotation on a Cylinder 1245 virtual Cylinder& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 1246 //! apply a rotation on a Cylinder 1247 virtual Cylinder& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 1248 //! apply a rotation on a Cylinder 1249 virtual Cylinder& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 1250 //! apply a homothety on a Cylinder 1251 virtual Cylinder& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 1252 //! apply a homothety on a Cylinder 1253 virtual Cylinder& homothetize(real_t factor); 1254 //! apply a point reflection on a Cylinder 1255 virtual Cylinder& pointReflect(const Point& c = Point(0.,0.,0.)); 1256 //! apply a reflection2d on a Cylinder 1257 virtual Cylinder& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 1258 //! apply a reflection2d on a Cylinder 1259 virtual Cylinder& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 1260 //! apply a reflection3d on a Cylinder 1261 virtual Cylinder& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 1262 //! apply a reflection3d on a Cylinder 1263 virtual Cylinder& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 1264 }; 1265 1266 /*! 1267 \class Prism 1268 definition of a prismatic geometry in R^3 1269 */ 1270 class Prism : public Cylinder 1271 { 1272 private: 1273 bool isTriangular_; 1274 Point p3_; 1275 1276 public: 1277 //! default constructor 1278 Prism(); 1279 //! constructor with 2 Parameter 1280 Prism(const Parameter& p1, const Parameter& p2); 1281 //! constructor with 3 Parameter 1282 Prism(const Parameter& p1, const Parameter& p2, const Parameter& p3); 1283 //! constructor with 4 Parameter 1284 Prism(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 1285 //! constructor with 5 Parameter 1286 Prism(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 1287 //! constructor with 6 Parameter 1288 Prism(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1289 const Parameter& p6); 1290 //! constructor with 7 Parameter 1291 Prism(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1292 const Parameter& p6, const Parameter& p7); 1293 1294 protected: 1295 //@{ 1296 //! true constructor functions 1297 void buildPBasisNAndH(); 1298 void build(const std::vector<Parameter>& ps); 1299 void buildParam(const Parameter& gp); 1300 void buildDefaultParam(ParameterKey key); 1301 std::set<ParameterKey> getParamsKeys(); 1302 //@} 1303 1304 public: 1305 //! copy constructor 1306 Prism(const Prism& p); 1307 //! format as string 1308 virtual string_t asString() const; 1309 clone() const1310 virtual Geometry* clone() const { return new Prism(*this); } //!< virtual copy constructor 1311 1312 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces (const) 1313 virtual void collect(const string_t& n, std::list<Geometry*>&) const; //!< collect all canonical geometry's with name n 1314 1315 //! access to child Prism object (const) prism() const1316 virtual const Prism* prism() const {return this;} 1317 //! access to child Prism object prism()1318 virtual Prism* prism() {return this;} 1319 1320 //================================================ 1321 // transformations facilities 1322 //================================================ 1323 //! apply a geometrical transformation on a Prism 1324 virtual Prism& transform(const Transformation& t); 1325 //! apply a translation on a Prism (vector version) 1326 virtual Prism& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 1327 //! apply a translation on a Prism (3 reals version) 1328 virtual Prism& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 1329 //! apply a rotation on a Prism 1330 virtual Prism& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 1331 //! apply a rotation on a Prism 1332 virtual Prism& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 1333 real_t angle = 0.); 1334 //! apply a rotation on a Prism 1335 virtual Prism& rotate3d(real_t dx, real_t dy, real_t angle); 1336 //! apply a rotation on a Prism 1337 virtual Prism& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 1338 //! apply a rotation on a Prism 1339 virtual Prism& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 1340 //! apply a rotation on a Prism 1341 virtual Prism& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 1342 //! apply a homothety on a Prism 1343 virtual Prism& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 1344 //! apply a homothety on a Prism 1345 virtual Prism& homothetize(real_t factor); 1346 //! apply a point reflection on a Prism 1347 virtual Prism& pointReflect(const Point& c = Point(0.,0.,0.)); 1348 //! apply a reflection2d on a Prism 1349 virtual Prism& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 1350 //! apply a reflection2d on a Prism 1351 virtual Prism& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 1352 //! apply a reflection3d on a Prism 1353 virtual Prism& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 1354 //! apply a reflection3d on a Prism 1355 virtual Prism& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 1356 }; 1357 1358 /*! 1359 \class Cone 1360 A cylinder is a volume defined by a section (the basis) and a direction vector 1361 The direction vector is not necessarily orthogonal to the basis, but both bases are necessarily parallel 1362 A Cylinder is a Trunk with scale factor equal to 0 !!! 1363 */ 1364 class Cone : public Trunk 1365 { 1366 public: 1367 //! default constructor 1368 Cone(bool defineBasisAndP=true); 1369 //! default constructor with basis and apex 1370 Cone(const Surface& basis, const Point& apex); 1371 //! constructor with 2 Parameter 1372 Cone(const Parameter& p1, const Parameter& p2); 1373 //! constructor with 3 Parameter 1374 Cone(const Parameter& p1, const Parameter& p2, const Parameter& p3); 1375 //! constructor with 4 Parameter 1376 Cone(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 1377 //! constructor with 5 Parameter 1378 Cone(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 1379 //! constructor with 6 Parameter 1380 Cone(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1381 const Parameter& p6); 1382 //! constructor with 7 Parameter 1383 Cone(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1384 const Parameter& p6, const Parameter& p7); 1385 1386 protected: 1387 //@{ 1388 //! true constructor functions 1389 void buildPBasisNAndH(); 1390 void build(const std::vector<Parameter>& ps); 1391 void buildParam(const Parameter& gp); 1392 void buildDefaultParam(ParameterKey key); 1393 std::set<ParameterKey> getParamsKeys(); 1394 //@} 1395 1396 public: 1397 //! copy constructor 1398 Cone(const Cone& c); 1399 1400 //! accessor to apex_ apex() const1401 Point apex() const { return origin_; } 1402 1403 //! format as string 1404 virtual string_t asString() const; 1405 clone() const1406 virtual Geometry* clone() const { return new Cone(*this); } //!< virtual copy constructor 1407 1408 virtual std::vector<const Point*> boundNodes() const; //!< returns list of points on boundary (const) 1409 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > curves() const; //!< returns list of curves (const) 1410 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces (const) 1411 computeMB()1412 virtual void computeMB() 1413 { 1414 minimalBox= MinimalBox(basis_->minimalBox.boundPt(1), 1415 basis_->minimalBox.boundPt(2), 1416 basis_->minimalBox.boundPt(3), 1417 origin_); 1418 } 1419 1420 //! access to child Cone object (const) cone() const1421 virtual const Cone* cone() const {return this;} 1422 //! access to child Cone2d object cone()1423 virtual Cone* cone() {return this;} 1424 1425 //================================================ 1426 // transformations facilities 1427 //================================================ 1428 //! apply a geometrical transformation on a Cone 1429 virtual Cone& transform(const Transformation& t); 1430 //! apply a translation on a Cone (vector version) 1431 virtual Cone& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 1432 //! apply a translation on a Cone (3 reals version) 1433 virtual Cone& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 1434 //! apply a rotation on a Cone 1435 virtual Cone& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 1436 //! apply a rotation on a Cone 1437 virtual Cone& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 1438 real_t angle = 0.); 1439 //! apply a rotation on a Cone 1440 virtual Cone& rotate3d(real_t dx, real_t dy, real_t angle); 1441 //! apply a rotation on a Cone 1442 virtual Cone& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 1443 //! apply a rotation on a Cone 1444 virtual Cone& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 1445 //! apply a rotation on a Cone 1446 virtual Cone& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 1447 //! apply a homothety on a Cone 1448 virtual Cone& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 1449 //! apply a homothety on a Cone 1450 virtual Cone& homothetize(real_t factor); 1451 //! apply a point reflection on a Cone 1452 virtual Cone& pointReflect(const Point& c = Point(0.,0.,0.)); 1453 //! apply a reflection2d on a Cone 1454 virtual Cone& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 1455 //! apply a reflection2d on a Cone 1456 virtual Cone& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 1457 //! apply a reflection3d on a Cone 1458 virtual Cone& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 1459 //! apply a reflection3d on a Cone 1460 virtual Cone& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 1461 }; 1462 1463 /*! 1464 \class Pyramid 1465 definition of a pyramidal geometry in R^3 1466 */ 1467 class Pyramid : public Cone 1468 { 1469 private: 1470 bool isQuadrangular_; 1471 Point p3_, p4_; 1472 1473 public: 1474 //! default constructor 1475 Pyramid(); 1476 //! constructor with 2 Parameter 1477 Pyramid(const Parameter& p1, const Parameter& p2); 1478 //! constructor with 3 Parameter 1479 Pyramid(const Parameter& p1, const Parameter& p2, const Parameter& p3); 1480 //! constructor with 4 Parameter 1481 Pyramid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 1482 //! constructor with 5 Parameter 1483 Pyramid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 1484 //! constructor with 6 Parameter 1485 Pyramid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1486 const Parameter& p6); 1487 //! constructor with 7 Parameter 1488 Pyramid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1489 const Parameter& p6, const Parameter& p7); 1490 //! constructor with 8 Parameter 1491 Pyramid(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1492 const Parameter& p6, const Parameter& p7, const Parameter& p8); 1493 1494 protected: 1495 //@{ 1496 //! true constructor functions 1497 void buildPBasisNAndH(); 1498 void build(const std::vector<Parameter>& ps); 1499 void buildParam(const Parameter& gp); 1500 void buildDefaultParam(ParameterKey key); 1501 std::set<ParameterKey> getParamsKeys(); 1502 //@} 1503 1504 public: 1505 //! copy constructor 1506 Pyramid(const Pyramid& p); 1507 1508 //@{ 1509 //! accessor to point p1() const1510 Point p1() const { return p_[0]; } p2() const1511 Point p2() const { return p_[1]; } p3() const1512 Point p3() const { return p_[2]; } p4() const1513 Point p4() const { return p_[3]; } p5() const1514 Point p5() const { return p_[4]; } 1515 //@} 1516 1517 //@{ 1518 //! accessor to number of element on edge n1() const1519 number_t n1() const {return n_[0];} n2() const1520 number_t n2() const {return n_[1];} n3() const1521 number_t n3() const {return n_[2];} n4() const1522 number_t n4() const {return n_[3];} n5() const1523 number_t n5() const {return n_[4];} n6() const1524 number_t n6() const {return n_[5];} n7() const1525 number_t n7() const {return n_[6];} n8() const1526 number_t n8() const {return n_[7];} 1527 //@} 1528 1529 //! format as string 1530 virtual string_t asString() const; 1531 clone() const1532 virtual Geometry* clone() const { return new Pyramid(*this); } //!< virtual copy constructor 1533 1534 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces (const) 1535 virtual void collect(const string_t& n, std::list<Geometry*>&) const; //!< collect in a all canonical geometry's with name n 1536 1537 //! access to child Pyramid object (const) pyramid() const1538 virtual const Pyramid* pyramid() const {return this;} 1539 //! access to child Pyramid object pyramid()1540 virtual Pyramid* pyramid() {return this;} 1541 1542 //================================================ 1543 // transformations facilities 1544 //================================================ 1545 //! apply a geometrical transformation on a Pyramid 1546 virtual Pyramid& transform(const Transformation& t); 1547 //! apply a translation on a Pyramid (vector version) 1548 virtual Pyramid& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 1549 //! apply a translation on a Pyramid (3 reals version) 1550 virtual Pyramid& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 1551 //! apply a rotation on a Pyramid 1552 virtual Pyramid& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 1553 //! apply a rotation on a Pyramid 1554 virtual Pyramid& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 1555 real_t angle = 0.); 1556 //! apply a rotation on a Pyramid 1557 virtual Pyramid& rotate3d(real_t dx, real_t dy, real_t angle); 1558 //! apply a rotation on a Pyramid 1559 virtual Pyramid& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 1560 //! apply a rotation on a Pyramid 1561 virtual Pyramid& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 1562 //! apply a rotation on a Pyramid 1563 virtual Pyramid& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 1564 //! apply a homothety on a Pyramid 1565 virtual Pyramid& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 1566 //! apply a homothety on a Pyramid 1567 virtual Pyramid& homothetize(real_t factor); 1568 //! apply a point reflection on a Pyramid 1569 virtual Pyramid& pointReflect(const Point& c = Point(0.,0.,0.)); 1570 //! apply a reflection2d on a Pyramid 1571 virtual Pyramid& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 1572 //! apply a reflection2d on a Pyramid 1573 virtual Pyramid& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 1574 //! apply a reflection3d on a Pyramid 1575 virtual Pyramid& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 1576 //! apply a reflection3d on a Pyramid 1577 virtual Pyramid& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 1578 }; 1579 1580 /*! 1581 \class RevTrunk 1582 A object of revolution is defined by its axis (P1,P2) and the radii of two circles 1583 obtained by intersection with a plane orthogonal to (P1,P2). The object is delimited 1584 by the two planes, orthogonal to (P1,P2), passing by P1 and P2, and this is the default 1585 end shape of the object when it is meshed with volumic elements (gesFlat or equivalently 1586 in this case, gesNone). 1587 When the elements are surfacic, the default is to leave the ends empty (gesNone). 1588 1589 Moreover, on both ends of this object, one can add part of a cone (gesCone), an ellipsoid 1590 (gesEllipsoid) or a sphere (gesSphere), connected to the boundary circle of the object. 1591 Let us consider the boundary circle whose center is P1. The apex of the cone or the ellipsoid 1592 is assumed to lie on the line (P1,P2) at a given distance distance1_ from P1. This distance 1593 is irrelevant in the case of the sphere. The same apply on the other end of the object. 1594 When the elements are surfacic, one can additonnaly chose a flat "lid" (gesFlat) ; the 1595 distance argument is then also irrelevant in this case. 1596 */ 1597 class RevTrunk : public Trunk 1598 { 1599 protected: 1600 real_t radius1_, radius2_; 1601 number_t nbSubDomains_; //!< number of main subDomains 1602 GeometricEndShape endShape1_; //!< shape of the first end 1603 real_t distance1_; //!< height of the first end 1604 GeometricEndShape endShape2_; //!< shape of the second end 1605 real_t distance2_; //!< height of the second end 1606 dimen_t type_; //!< type of the subdivision 1607 1608 public: 1609 //! default constructor 1610 RevTrunk(real_t scale=1., bool defineBasisAndP=true); 1611 //! constructor with 4 Parameter 1612 RevTrunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 1613 //! constructor with 5 Parameter 1614 RevTrunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 1615 //! constructor with 6 Parameter 1616 RevTrunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1617 const Parameter& p6); 1618 //! constructor with 7 Parameter 1619 RevTrunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1620 const Parameter& p6, const Parameter& p7); 1621 //! constructor with 8 Parameter 1622 RevTrunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1623 const Parameter& p6, const Parameter& p7, const Parameter& p8); 1624 //! constructor with 9 Parameter 1625 RevTrunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1626 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9); 1627 //! constructor with 10 Parameter 1628 RevTrunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1629 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9, const Parameter& p10); 1630 //! constructor with 11 Parameter 1631 RevTrunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1632 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9, const Parameter& p10, 1633 const Parameter& p11); 1634 //! constructor with 12 Parameter 1635 RevTrunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1636 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9, const Parameter& p10, 1637 const Parameter& p11, const Parameter& p12); 1638 //! constructor with 13 Parameter 1639 RevTrunk(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1640 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9, const Parameter& p10, 1641 const Parameter& p11, const Parameter& p12, const Parameter& p13); 1642 1643 protected: 1644 //@{ 1645 //! true constructor functions 1646 void buildP(); 1647 void buildPScaleAndBasis(); 1648 void build(const std::vector<Parameter>& ps); 1649 void buildParam(const Parameter& gp); 1650 void buildDefaultParam(ParameterKey key); 1651 std::set<ParameterKey> getParamsKeys(); 1652 //@} 1653 1654 public: 1655 //! copy constructor 1656 RevTrunk(const RevTrunk& r); 1657 //! format as string : "RevTrunk (P1=(.,.,.), P2=(.,.,.), radius=R, end1=., end2=., d1=., d2=.)" 1658 virtual string_t asString() const; 1659 radius1() const1660 real_t radius1() const { return radius1_; } //!< returns radius of first basis radius2() const1661 real_t radius2() const { return radius2_; } //!< returns radius of second basis endShape1() const1662 GeometricEndShape endShape1() const { return endShape1_; } //!< returns shape of first end endShape2() const1663 GeometricEndShape endShape2() const { return endShape2_; } //!< returns shape of second end distance1() const1664 real_t distance1() const { return distance1_; } //!< returns height of first end distance2() const1665 real_t distance2() const { return distance2_; } //!< returns height of second end 1666 nbSubdomains() const1667 virtual number_t nbSubdomains() const { return nbSubDomains_; } //!< returns number of elements on lateral edges 1668 virtual number_t nbSubdiv() const; //!< returns number of subdivisions type() const1669 virtual dimen_t type() const { return type_; } //!< returns type of subdivision 1670 clone() const1671 virtual Geometry* clone() const { return new RevTrunk(*this); } //!< virtual copy constructor 1672 1673 //! access to child RevTrunk object (const) revTrunk() const1674 virtual const RevTrunk* revTrunk() const {return this;} 1675 //! access to child RevTrunk object revTrunk()1676 virtual RevTrunk* revTrunk() {return this;} 1677 1678 //================================================ 1679 // transformations facilities 1680 //================================================ 1681 //! apply a geometrical transformation on a RevTrunk 1682 virtual RevTrunk& transform(const Transformation& t); 1683 //! apply a translation on a RevTrunk (vector version) 1684 virtual RevTrunk& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 1685 //! apply a translation on a RevTrunk (3 reals version) 1686 virtual RevTrunk& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 1687 //! apply a rotation on a RevTrunk 1688 virtual RevTrunk& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 1689 //! apply a rotation on a RevTrunk 1690 virtual RevTrunk& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 1691 real_t angle = 0.); 1692 //! apply a rotation on a RevTrunk 1693 virtual RevTrunk& rotate3d(real_t dx, real_t dy, real_t angle); 1694 //! apply a rotation on a RevTrunk 1695 virtual RevTrunk& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 1696 //! apply a rotation on a RevTrunk 1697 virtual RevTrunk& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 1698 //! apply a rotation on a RevTrunk 1699 virtual RevTrunk& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 1700 //! apply a homothety on a RevTrunk 1701 virtual RevTrunk& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 1702 //! apply a homothety on a RevTrunk 1703 virtual RevTrunk& homothetize(real_t factor); 1704 //! apply a point reflection on a RevTrunk 1705 virtual RevTrunk& pointReflect(const Point& c = Point(0.,0.,0.)); 1706 //! apply a reflection2d on a RevTrunk 1707 virtual RevTrunk& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 1708 //! apply a reflection2d on a RevTrunk 1709 virtual RevTrunk& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 1710 //! apply a reflection3d on a RevTrunk 1711 virtual RevTrunk& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 1712 //! apply a reflection3d on a RevTrunk 1713 virtual RevTrunk& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 1714 }; 1715 1716 /*! 1717 \class RevCylinder 1718 A cylinder of revolution is defined by its axis (P1,P2) and the radius of any circle 1719 obtained by intersection with a plane orthogonal to (P1,P2). 1720 See more details at RevTrunk. 1721 */ 1722 class RevCylinder : public RevTrunk 1723 { 1724 public: 1725 //! default constructor 1726 RevCylinder(); 1727 //! constructor with 3 Parameter 1728 RevCylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3); 1729 //! constructor with 4 Parameter 1730 RevCylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 1731 //! constructor with 5 Parameter 1732 RevCylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 1733 //! constructor with 6 Parameter 1734 RevCylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1735 const Parameter& p6); 1736 //! constructor with 7 Parameter 1737 RevCylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1738 const Parameter& p6, const Parameter& p7); 1739 //! constructor with 8 Parameter 1740 RevCylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1741 const Parameter& p6, const Parameter& p7, const Parameter& p8); 1742 //! constructor with 9 Parameter 1743 RevCylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1744 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9); 1745 //! constructor with 10 Parameter 1746 RevCylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1747 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9, const Parameter& p10); 1748 //! constructor with 11 Parameter 1749 RevCylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1750 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9, const Parameter& p10, 1751 const Parameter& p11); 1752 //! constructor with 12 Parameter 1753 RevCylinder(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1754 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9, const Parameter& p10, 1755 const Parameter& p11, const Parameter& p12); 1756 1757 protected: 1758 //@{ 1759 //! true constructor functions 1760 void build(const std::vector<Parameter>& ps); 1761 void buildParam(const Parameter& gp); 1762 void buildDefaultParam(ParameterKey key); 1763 std::set<ParameterKey> getParamsKeys(); 1764 //@} 1765 1766 public: 1767 //! format as string 1768 virtual string_t asString() const; 1769 clone() const1770 virtual Geometry* clone() const { return new RevCylinder(*this); } //!< virtual copy constructor 1771 1772 //! computes the minimal box computeMB()1773 virtual void computeMB() 1774 { 1775 minimalBox= MinimalBox(basis_->minimalBox.boundPt(1), basis_->minimalBox.boundPt(2), basis_->minimalBox.boundPt(3), 1776 basis_->minimalBox.boundPt(1)+origin_-center1_); 1777 } 1778 1779 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces (const) 1780 1781 //! access to child RevCylinder object (const) revCylinder() const1782 virtual const RevCylinder* revCylinder() const {return this;} 1783 //! access to child RevCylinder object revCylinder()1784 virtual RevCylinder* revCylinder() {return this;} 1785 1786 //================================================ 1787 // transformations facilities 1788 //================================================ 1789 //! apply a geometrical transformation on a RevCylinder 1790 virtual RevCylinder& transform(const Transformation& t); 1791 //! apply a translation on a RevCylinder (vector version) 1792 virtual RevCylinder& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 1793 //! apply a translation on a RevCylinder (3 reals version) 1794 virtual RevCylinder& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 1795 //! apply a rotation on a RevCylinder 1796 virtual RevCylinder& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 1797 //! apply a rotation on a RevCylinder 1798 virtual RevCylinder& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 1799 real_t angle = 0.); 1800 //! apply a rotation on a RevCylinder 1801 virtual RevCylinder& rotate3d(real_t dx, real_t dy, real_t angle); 1802 //! apply a rotation on a RevCylinder 1803 virtual RevCylinder& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 1804 //! apply a rotation on a RevCylinder 1805 virtual RevCylinder& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 1806 //! apply a rotation on a RevCylinder 1807 virtual RevCylinder& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 1808 //! apply a homothety on a RevCylinder 1809 virtual RevCylinder& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 1810 //! apply a homothety on a RevCylinder 1811 virtual RevCylinder& homothetize(real_t factor); 1812 //! apply a point reflection on a RevCylinder 1813 virtual RevCylinder& pointReflect(const Point& c = Point(0.,0.,0.)); 1814 //! apply a reflection2d on a RevCylinder 1815 virtual RevCylinder& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 1816 //! apply a reflection2d on a RevCylinder 1817 virtual RevCylinder& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 1818 //! apply a reflection3d on a RevCylinder 1819 virtual RevCylinder& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 1820 //! apply a reflection3d on a RevCylinder 1821 virtual RevCylinder& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 1822 }; 1823 1824 /*! 1825 \class RevCone 1826 A truncated cone of revolution is defined by its axis (P1,P2) and two radii R1 and R2. 1827 R1 (resp. R2) is the radius of the circle lying in the plane orthogonal to (P1,P2) passing 1828 by P1 (resp. P2). 1829 R1 (or R2) can be 0, in which case we get a cone of revolution. 1830 See more details at RevTrunk. 1831 */ 1832 class RevCone : public RevTrunk 1833 { 1834 public: 1835 //! default constructor 1836 RevCone(); 1837 //! constructor with 3 Parameter 1838 RevCone(const Parameter& p1, const Parameter& p2, const Parameter& p3); 1839 //! constructor with 4 Parameter 1840 RevCone(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4); 1841 //! constructor with 5 Parameter 1842 RevCone(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5); 1843 //! constructor with 6 Parameter 1844 RevCone(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1845 const Parameter& p6); 1846 //! constructor with 7 Parameter 1847 RevCone(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1848 const Parameter& p6, const Parameter& p7); 1849 //! constructor with 8 Parameter 1850 RevCone(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1851 const Parameter& p6, const Parameter& p7, const Parameter& p8); 1852 //! constructor with 9 Parameter 1853 RevCone(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1854 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9); 1855 //! constructor with 10 Parameter 1856 RevCone(const Parameter& p1, const Parameter& p2, const Parameter& p3, const Parameter& p4, const Parameter& p5, 1857 const Parameter& p6, const Parameter& p7, const Parameter& p8, const Parameter& p9, const Parameter& p10); 1858 1859 protected: 1860 //@{ 1861 //! true constructor functions 1862 void build(const std::vector<Parameter>& ps); 1863 void buildParam(const Parameter& gp); 1864 void buildDefaultParam(ParameterKey key); 1865 std::set<ParameterKey> getParamsKeys(); 1866 //@} 1867 1868 public: 1869 //! accessor to apex_ apex() const1870 Point apex() const { return origin_; } 1871 1872 //! format as string 1873 virtual string_t asString() const; 1874 clone() const1875 virtual Geometry* clone() const { return new RevCone(*this); } //!< virtual copy constructor 1876 1877 virtual std::vector<const Point*> boundNodes() const; //!< returns list of points on boundary (const) 1878 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > curves() const; //!< returns list of curves (const) 1879 virtual std::vector<std::pair<ShapeType,std::vector<const Point*> > > surfs() const; //!< returns list of faces (const) 1880 computeMB()1881 virtual void computeMB() 1882 { 1883 minimalBox= MinimalBox(basis_->minimalBox.boundPt(1), 1884 basis_->minimalBox.boundPt(2), 1885 basis_->minimalBox.boundPt(3), 1886 origin_); 1887 } 1888 1889 //! access to child RevCone object (const) revCone() const1890 virtual const RevCone* revCone() const {return this;} 1891 //! access to child RevCone object revCone()1892 virtual RevCone* revCone() {return this;} 1893 1894 //================================================ 1895 // transformations facilities 1896 //================================================ 1897 //! apply a geometrical transformation on a RevCone 1898 virtual RevCone& transform(const Transformation& t); 1899 //! apply a translation on a RevCone (vector version) 1900 virtual RevCone& translate(std::vector<real_t> u = std::vector<real_t>(3,0.)); 1901 //! apply a translation on a RevCone (3 reals version) 1902 virtual RevCone& translate(real_t ux, real_t uy = 0., real_t uz = 0.); 1903 //! apply a rotation on a RevCone 1904 virtual RevCone& rotate2d(const Point& c = Point(0.,0.), real_t angle = 0.); 1905 //! apply a rotation on a RevCone 1906 virtual RevCone& rotate3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> d = std::vector<real_t>(3,0.), 1907 real_t angle = 0.); 1908 //! apply a rotation on a RevCone 1909 virtual RevCone& rotate3d(real_t dx, real_t dy, real_t angle); 1910 //! apply a rotation on a RevCone 1911 virtual RevCone& rotate3d(real_t dx, real_t dy, real_t dz, real_t angle); 1912 //! apply a rotation on a RevCone 1913 virtual RevCone& rotate3d(const Point& c, real_t dx, real_t dy, real_t angle); 1914 //! apply a rotation on a RevCone 1915 virtual RevCone& rotate3d(const Point& c, real_t dx, real_t dy, real_t dz, real_t angle); 1916 //! apply a homothety on a RevCone 1917 virtual RevCone& homothetize(const Point& c = Point(0.,0.,0.), real_t factor = 1.); 1918 //! apply a homothety on a RevCone 1919 virtual RevCone& homothetize(real_t factor); 1920 //! apply a point reflection on a RevCone 1921 virtual RevCone& pointReflect(const Point& c = Point(0.,0.,0.)); 1922 //! apply a reflection2d on a RevCone 1923 virtual RevCone& reflect2d(const Point& c = Point(0.,0.), std::vector<real_t> d = std::vector<real_t>(2,0.)); 1924 //! apply a reflection2d on a RevCone 1925 virtual RevCone& reflect2d(const Point& c, real_t dx, real_t dy = 0.); 1926 //! apply a reflection3d on a RevCone 1927 virtual RevCone& reflect3d(const Point& c = Point(0.,0.,0.), std::vector<real_t> n = std::vector<real_t>(3,0.)); 1928 //! apply a reflection3d on a RevCone 1929 virtual RevCone& reflect3d(const Point& c, real_t nx, real_t ny, real_t nz = 0.); 1930 }; 1931 1932 } // end of namespace xlifepp 1933 1934 #endif // GEOMETRIES_3D_HPP 1935