[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[bcf653] | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[997784] | 8 | /*
|
---|
| 9 | * Shape.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: Jun 18, 2010
|
---|
| 12 | * Author: crueger
|
---|
| 13 | */
|
---|
| 14 |
|
---|
[bf3817] | 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
[ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
|
---|
[997784] | 21 |
|
---|
[ad011c] | 22 | #include "CodePatterns/Assert.hpp"
|
---|
[6c438f] | 23 | #include "LinearAlgebra/Vector.hpp"
|
---|
| 24 |
|
---|
[b94634] | 25 | #include "Shapes/Shape.hpp"
|
---|
| 26 | #include "Shapes/Shape_impl.hpp"
|
---|
| 27 | #include "Shapes/ShapeExceptions.hpp"
|
---|
[b92e4a] | 28 | #include "Shapes/ShapeType.hpp"
|
---|
[5de9da] | 29 |
|
---|
[6acc2f3] | 30 | #include <algorithm>
|
---|
| 31 | #include <limits>
|
---|
[cfda65] | 32 | #include <string>
|
---|
| 33 |
|
---|
| 34 |
|
---|
[997784] | 35 | Shape::Shape(const Shape& src) :
|
---|
| 36 | impl(src.getImpl())
|
---|
| 37 | {}
|
---|
| 38 |
|
---|
| 39 | Shape::~Shape(){}
|
---|
| 40 |
|
---|
[205d9b] | 41 | bool Shape::isInside(const Vector &point) const{
|
---|
[997784] | 42 | return impl->isInside(point);
|
---|
| 43 | }
|
---|
| 44 |
|
---|
[5de9da] | 45 | bool Shape::isOnSurface(const Vector &point) const{
|
---|
| 46 | return impl->isOnSurface(point);
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | Vector Shape::getNormal(const Vector &point) const throw (NotOnSurfaceException){
|
---|
| 50 | return impl->getNormal(point);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
[6acc2f3] | 53 | Vector Shape::getCenter() const{
|
---|
| 54 | return impl->getCenter();
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | double Shape::getRadius() const{
|
---|
| 58 | return impl->getRadius();
|
---|
| 59 | }
|
---|
| 60 |
|
---|
[c67c65] | 61 | /** Returns the volume of the Shape.
|
---|
| 62 | *
|
---|
| 63 | * If the underlying implementation does not have a working implementation,
|
---|
| 64 | * i.e. returns -1., then we use an approximate method to calculate the
|
---|
| 65 | * volume via a mesh of grid points and checking for isInside (basically
|
---|
| 66 | * a Monte-Carlo integration of the volume).
|
---|
| 67 | *
|
---|
| 68 | * \return volume of the shape
|
---|
| 69 | */
|
---|
| 70 | double Shape::getVolume() const
|
---|
| 71 | {
|
---|
| 72 | const double volume = impl->getVolume();
|
---|
| 73 | if (volume != -1.) {
|
---|
| 74 | return volume;
|
---|
| 75 | } else {
|
---|
| 76 | ASSERT(0, "Shape::getVolume() - functionality not implemented for this specific shape.");
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | /** Returns the surface area of the Shape.
|
---|
| 81 | *
|
---|
| 82 | * If the underlying implementation does not have a working implementation,
|
---|
| 83 | * i.e. returns -1., then we use the working filling of the shapes surface
|
---|
| 84 | * with points and subsequent tesselation and obtaining the approximate
|
---|
| 85 | * surface area therefrom.
|
---|
| 86 | *
|
---|
| 87 | * @return surface area of the Shape
|
---|
| 88 | */
|
---|
| 89 | double Shape::getSurfaceArea() const
|
---|
| 90 | {
|
---|
| 91 | const double surfacearea = impl->getSurfaceArea();
|
---|
| 92 | if (surfacearea != -1.) {
|
---|
| 93 | return surfacearea;
|
---|
| 94 | } else {
|
---|
| 95 | ASSERT(0, "Shape::getSurfaceArea() - functionality not implemented for this specific shape.");
|
---|
| 96 | }
|
---|
| 97 | }
|
---|
| 98 |
|
---|
[735940] | 99 | LineSegmentSet Shape::getLineIntersections(const Line &line) const{
|
---|
[c6f395] | 100 | return impl->getLineIntersections(line);
|
---|
| 101 | }
|
---|
| 102 |
|
---|
[9c1c89] | 103 | std::vector<Vector> Shape::getHomogeneousPointsOnSurface(const size_t N) const {
|
---|
[c5186e] | 104 | return impl->getHomogeneousPointsOnSurface(N);
|
---|
| 105 | }
|
---|
| 106 |
|
---|
[5a8d61] | 107 | std::vector<Vector> Shape::getHomogeneousPointsInVolume(const size_t N) const {
|
---|
| 108 | return impl->getHomogeneousPointsInVolume(N);
|
---|
| 109 | }
|
---|
| 110 |
|
---|
[997784] | 111 | Shape::Shape(Shape::impl_ptr _impl) :
|
---|
| 112 | impl(_impl)
|
---|
| 113 | {}
|
---|
| 114 |
|
---|
| 115 | Shape &Shape::operator=(const Shape& rhs){
|
---|
| 116 | if(&rhs!=this){
|
---|
| 117 | impl=rhs.getImpl();
|
---|
| 118 | }
|
---|
| 119 | return *this;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
[b92e4a] | 122 | bool Shape::operator==(const Shape &rhs) const{
|
---|
| 123 | return (this->getType() == rhs.getType());
|
---|
| 124 | }
|
---|
| 125 |
|
---|
[cfda65] | 126 | std::string Shape::toString() const{
|
---|
| 127 | return impl->toString();
|
---|
| 128 | }
|
---|
| 129 |
|
---|
[b92e4a] | 130 | enum ShapeType Shape::getType() const{
|
---|
| 131 | return impl->getType();
|
---|
| 132 | }
|
---|
| 133 |
|
---|
[997784] | 134 | Shape::impl_ptr Shape::getImpl() const{
|
---|
| 135 | return impl;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
[e09b70] | 138 | // allows arbitrary friendship, but only if implementation is known
|
---|
| 139 | Shape::impl_ptr getShapeImpl(const Shape &shape){
|
---|
| 140 | return shape.getImpl();
|
---|
| 141 | }
|
---|
| 142 |
|
---|
[997784] | 143 | /***************************** Some simple Shapes ***************************/
|
---|
| 144 |
|
---|
| 145 | Shape Everywhere(){
|
---|
| 146 | static Shape::impl_ptr impl = Shape::impl_ptr(new Everywhere_impl());
|
---|
| 147 | return Shape(impl);
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | Shape Nowhere(){
|
---|
| 151 | static Shape::impl_ptr impl = Shape::impl_ptr(new Nowhere_impl());
|
---|
| 152 | return Shape(impl);
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | /****************************** Operators ***********************************/
|
---|
| 156 |
|
---|
| 157 | // AND
|
---|
| 158 |
|
---|
| 159 | AndShape_impl::AndShape_impl(const Shape::impl_ptr &_lhs, const Shape::impl_ptr &_rhs) :
|
---|
| 160 | lhs(_lhs),rhs(_rhs)
|
---|
| 161 | {}
|
---|
| 162 |
|
---|
| 163 | AndShape_impl::~AndShape_impl(){}
|
---|
| 164 |
|
---|
[735940] | 165 | bool AndShape_impl::isInside(const Vector &point) const{
|
---|
[997784] | 166 | return lhs->isInside(point) && rhs->isInside(point);
|
---|
| 167 | }
|
---|
| 168 |
|
---|
[735940] | 169 | bool AndShape_impl::isOnSurface(const Vector &point) const{
|
---|
[5de9da] | 170 | // check the number of surfaces that this point is on
|
---|
| 171 | int surfaces =0;
|
---|
| 172 | surfaces += lhs->isOnSurface(point);
|
---|
| 173 | surfaces += rhs->isOnSurface(point);
|
---|
| 174 |
|
---|
| 175 | switch(surfaces){
|
---|
| 176 | case 0:
|
---|
| 177 | return false;
|
---|
| 178 | // no break necessary
|
---|
| 179 | case 1:
|
---|
| 180 | // if it is inside for the object where it does not lie on
|
---|
| 181 | // the surface the whole point lies inside
|
---|
[ef84ca] | 182 | return (lhs->isOnSurface(point) && rhs->isInside(point)) ||
|
---|
| 183 | (rhs->isOnSurface(point) && lhs->isInside(point));
|
---|
[5de9da] | 184 | // no break necessary
|
---|
| 185 | case 2:
|
---|
| 186 | {
|
---|
| 187 | // it lies on both Shapes... could be an edge or an inner point
|
---|
| 188 | // test the direction of the normals
|
---|
| 189 | Vector direction=lhs->getNormal(point)+rhs->getNormal(point);
|
---|
| 190 | // if the directions are opposite we lie on the inside
|
---|
| 191 | return !direction.IsZero();
|
---|
| 192 | }
|
---|
| 193 | // no break necessary
|
---|
| 194 | default:
|
---|
| 195 | // if this happens there is something wrong
|
---|
| 196 | ASSERT(0,"Default case should have never been used");
|
---|
| 197 | }
|
---|
| 198 | return false; // never reached
|
---|
| 199 | }
|
---|
| 200 |
|
---|
[735940] | 201 | Vector AndShape_impl::getNormal(const Vector &point) const throw (NotOnSurfaceException){
|
---|
[5de9da] | 202 | Vector res;
|
---|
| 203 | if(!isOnSurface(point)){
|
---|
[b94634] | 204 | throw NotOnSurfaceException() << ShapeVector(&point);
|
---|
[5de9da] | 205 | }
|
---|
| 206 | res += lhs->isOnSurface(point)?lhs->getNormal(point):zeroVec;
|
---|
| 207 | res += rhs->isOnSurface(point)?rhs->getNormal(point):zeroVec;
|
---|
| 208 | res.Normalize();
|
---|
| 209 | return res;
|
---|
| 210 | }
|
---|
| 211 |
|
---|
[6acc2f3] | 212 | Vector AndShape_impl::getCenter() const
|
---|
| 213 | {
|
---|
| 214 | // calculate closest position on sphere surface to other center ..
|
---|
| 215 | const Vector rhsDistance = rhs->getCenter() + rhs->getRadius()*((lhs->getCenter() - rhs->getCenter()).getNormalized());
|
---|
| 216 | const Vector lhsDistance = lhs->getCenter() + lhs->getRadius()*((rhs->getCenter() - lhs->getCenter()).getNormalized());
|
---|
| 217 | // .. and then it's right in between those two
|
---|
| 218 | return 0.5*(rhsDistance + lhsDistance);
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 | double AndShape_impl::getRadius() const
|
---|
| 222 | {
|
---|
| 223 | const double distance = (lhs->getCenter() - rhs->getCenter()).Norm();
|
---|
| 224 | const double minradii = std::min(lhs->getRadius(), rhs->getRadius());
|
---|
| 225 | // if no intersection
|
---|
| 226 | if (distance > (lhs->getRadius() + rhs->getRadius()))
|
---|
| 227 | return 0.;
|
---|
| 228 | else // if intersection it can only be the smaller one
|
---|
| 229 | return minradii;
|
---|
| 230 | }
|
---|
| 231 |
|
---|
[c67c65] | 232 | double AndShape_impl::getVolume() const
|
---|
| 233 | {
|
---|
| 234 | // TODO
|
---|
| 235 | return -1.;
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | double AndShape_impl::getSurfaceArea() const
|
---|
| 239 | {
|
---|
| 240 | // TODO
|
---|
| 241 | return -1.;
|
---|
| 242 | }
|
---|
| 243 |
|
---|
[735940] | 244 | LineSegmentSet AndShape_impl::getLineIntersections(const Line &line) const{
|
---|
[c6f395] | 245 | return intersect(lhs->getLineIntersections(line),rhs->getLineIntersections(line));
|
---|
| 246 | }
|
---|
| 247 |
|
---|
[b92e4a] | 248 | std::string AndShape_impl::toString() const{
|
---|
[955b91] | 249 | return std::string("(") + lhs->toString() + std::string("&&") + rhs->toString() + std::string(")");
|
---|
[cfda65] | 250 | }
|
---|
| 251 |
|
---|
[b92e4a] | 252 | enum ShapeType AndShape_impl::getType() const{
|
---|
| 253 | return CombinedType;
|
---|
| 254 | }
|
---|
| 255 |
|
---|
[9c1c89] | 256 | std::vector<Vector> AndShape_impl::getHomogeneousPointsOnSurface(const size_t N) const {
|
---|
[23bade] | 257 | std::vector<Vector> PointsOnSurface_lhs = lhs->getHomogeneousPointsOnSurface(N);
|
---|
| 258 | std::vector<Vector> PointsOnSurface_rhs = rhs->getHomogeneousPointsOnSurface(N);
|
---|
[c5186e] | 259 | std::vector<Vector> PointsOnSurface;
|
---|
[23bade] | 260 |
|
---|
| 261 | for (std::vector<Vector>::const_iterator iter = PointsOnSurface_lhs.begin(); iter != PointsOnSurface_lhs.end(); ++iter) {
|
---|
| 262 | if (rhs->isInside(*iter))
|
---|
| 263 | PointsOnSurface.push_back(*iter);
|
---|
| 264 | }
|
---|
| 265 | for (std::vector<Vector>::const_iterator iter = PointsOnSurface_rhs.begin(); iter != PointsOnSurface_rhs.end(); ++iter) {
|
---|
| 266 | if (lhs->isInside(*iter))
|
---|
| 267 | PointsOnSurface.push_back(*iter);
|
---|
| 268 | }
|
---|
| 269 |
|
---|
[c5186e] | 270 | return PointsOnSurface;
|
---|
| 271 | }
|
---|
| 272 |
|
---|
[5a8d61] | 273 | std::vector<Vector> AndShape_impl::getHomogeneousPointsInVolume(const size_t N) const {
|
---|
| 274 | ASSERT(0,
|
---|
| 275 | "AndShape_impl::getHomogeneousPointsInVolume() - not implemented.");
|
---|
| 276 | return std::vector<Vector>();
|
---|
| 277 | }
|
---|
| 278 |
|
---|
[c5186e] | 279 |
|
---|
[997784] | 280 | Shape operator&&(const Shape &lhs,const Shape &rhs){
|
---|
[e09b70] | 281 | Shape::impl_ptr newImpl = Shape::impl_ptr(new AndShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
|
---|
[997784] | 282 | return Shape(newImpl);
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 | // OR
|
---|
| 286 |
|
---|
| 287 | OrShape_impl::OrShape_impl(const Shape::impl_ptr &_lhs, const Shape::impl_ptr &_rhs) :
|
---|
| 288 | lhs(_lhs),rhs(_rhs)
|
---|
| 289 | {}
|
---|
| 290 |
|
---|
| 291 | OrShape_impl::~OrShape_impl(){}
|
---|
| 292 |
|
---|
[735940] | 293 | bool OrShape_impl::isInside(const Vector &point) const{
|
---|
[997784] | 294 | return rhs->isInside(point) || lhs->isInside(point);
|
---|
| 295 | }
|
---|
| 296 |
|
---|
[735940] | 297 | bool OrShape_impl::isOnSurface(const Vector &point) const{
|
---|
[5de9da] | 298 | // check the number of surfaces that this point is on
|
---|
| 299 | int surfaces =0;
|
---|
| 300 | surfaces += lhs->isOnSurface(point);
|
---|
| 301 | surfaces += rhs->isOnSurface(point);
|
---|
| 302 |
|
---|
| 303 | switch(surfaces){
|
---|
| 304 | case 0:
|
---|
| 305 | return false;
|
---|
| 306 | // no break necessary
|
---|
| 307 | case 1:
|
---|
| 308 | // if it is inside for the object where it does not lie on
|
---|
| 309 | // the surface the whole point lies inside
|
---|
[ef84ca] | 310 | return (lhs->isOnSurface(point) && !rhs->isInside(point)) ||
|
---|
| 311 | (rhs->isOnSurface(point) && !lhs->isInside(point));
|
---|
[5de9da] | 312 | // no break necessary
|
---|
| 313 | case 2:
|
---|
| 314 | {
|
---|
| 315 | // it lies on both Shapes... could be an edge or an inner point
|
---|
| 316 | // test the direction of the normals
|
---|
| 317 | Vector direction=lhs->getNormal(point)+rhs->getNormal(point);
|
---|
| 318 | // if the directions are opposite we lie on the inside
|
---|
| 319 | return !direction.IsZero();
|
---|
| 320 | }
|
---|
| 321 | // no break necessary
|
---|
| 322 | default:
|
---|
| 323 | // if this happens there is something wrong
|
---|
| 324 | ASSERT(0,"Default case should have never been used");
|
---|
| 325 | }
|
---|
| 326 | return false; // never reached
|
---|
| 327 | }
|
---|
| 328 |
|
---|
[735940] | 329 | Vector OrShape_impl::getNormal(const Vector &point) const throw (NotOnSurfaceException){
|
---|
[5de9da] | 330 | Vector res;
|
---|
| 331 | if(!isOnSurface(point)){
|
---|
[b94634] | 332 | throw NotOnSurfaceException() << ShapeVector(&point);
|
---|
[5de9da] | 333 | }
|
---|
| 334 | res += lhs->isOnSurface(point)?lhs->getNormal(point):zeroVec;
|
---|
| 335 | res += rhs->isOnSurface(point)?rhs->getNormal(point):zeroVec;
|
---|
| 336 | res.Normalize();
|
---|
| 337 | return res;
|
---|
| 338 | }
|
---|
| 339 |
|
---|
[6acc2f3] | 340 | Vector OrShape_impl::getCenter() const
|
---|
| 341 | {
|
---|
| 342 | // calculate furthest position on sphere surface to other center ..
|
---|
| 343 | const Vector rhsDistance = rhs->getCenter() + rhs->getRadius()*((rhs->getCenter() - lhs->getCenter()).getNormalized());
|
---|
| 344 | const Vector lhsDistance = lhs->getCenter() + lhs->getRadius()*((lhs->getCenter() - rhs->getCenter()).getNormalized());
|
---|
| 345 | // .. and then it's right in between those two
|
---|
| 346 | return .5*(rhsDistance + lhsDistance);
|
---|
| 347 | }
|
---|
| 348 |
|
---|
| 349 | double OrShape_impl::getRadius() const
|
---|
| 350 | {
|
---|
| 351 | const Vector rhsDistance = rhs->getCenter() + rhs->getRadius()*((rhs->getCenter() - lhs->getCenter()).getNormalized());
|
---|
| 352 | const Vector lhsDistance = lhs->getCenter() + lhs->getRadius()*((lhs->getCenter() - rhs->getCenter()).getNormalized());
|
---|
| 353 | return .5*(rhsDistance - lhsDistance).Norm();
|
---|
| 354 | }
|
---|
| 355 |
|
---|
[c67c65] | 356 | double OrShape_impl::getVolume() const
|
---|
| 357 | {
|
---|
| 358 | // TODO
|
---|
| 359 | return -1.;
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | double OrShape_impl::getSurfaceArea() const
|
---|
| 363 | {
|
---|
| 364 | // TODO
|
---|
| 365 | return -1.;
|
---|
| 366 | }
|
---|
| 367 |
|
---|
[735940] | 368 | LineSegmentSet OrShape_impl::getLineIntersections(const Line &line) const{
|
---|
[c6f395] | 369 | return merge(lhs->getLineIntersections(line),rhs->getLineIntersections(line));
|
---|
| 370 | }
|
---|
| 371 |
|
---|
[b92e4a] | 372 | std::string OrShape_impl::toString() const{
|
---|
[955b91] | 373 | return std::string("(") + lhs->toString() + std::string("||") + rhs->toString() + std::string(")");
|
---|
[cfda65] | 374 | }
|
---|
| 375 |
|
---|
[b92e4a] | 376 | enum ShapeType OrShape_impl::getType() const{
|
---|
| 377 | return CombinedType;
|
---|
| 378 | }
|
---|
| 379 |
|
---|
[9c1c89] | 380 | std::vector<Vector> OrShape_impl::getHomogeneousPointsOnSurface(const size_t N) const {
|
---|
[c5186e] | 381 | std::vector<Vector> PointsOnSurface_lhs = lhs->getHomogeneousPointsOnSurface(N);
|
---|
| 382 | std::vector<Vector> PointsOnSurface_rhs = rhs->getHomogeneousPointsOnSurface(N);
|
---|
| 383 | std::vector<Vector> PointsOnSurface;
|
---|
| 384 |
|
---|
| 385 | for (std::vector<Vector>::const_iterator iter = PointsOnSurface_lhs.begin(); iter != PointsOnSurface_lhs.end(); ++iter) {
|
---|
| 386 | if (!rhs->isInside(*iter))
|
---|
| 387 | PointsOnSurface.push_back(*iter);
|
---|
| 388 | }
|
---|
| 389 | for (std::vector<Vector>::const_iterator iter = PointsOnSurface_rhs.begin(); iter != PointsOnSurface_rhs.end(); ++iter) {
|
---|
| 390 | if (!lhs->isInside(*iter))
|
---|
| 391 | PointsOnSurface.push_back(*iter);
|
---|
| 392 | }
|
---|
| 393 |
|
---|
| 394 | return PointsOnSurface;
|
---|
| 395 | }
|
---|
| 396 |
|
---|
[5a8d61] | 397 | std::vector<Vector> OrShape_impl::getHomogeneousPointsInVolume(const size_t N) const {
|
---|
| 398 | ASSERT(0,
|
---|
| 399 | "OrShape_impl::getHomogeneousPointsInVolume() - not implemented.");
|
---|
| 400 | return std::vector<Vector>();
|
---|
| 401 | }
|
---|
| 402 |
|
---|
[997784] | 403 | Shape operator||(const Shape &lhs,const Shape &rhs){
|
---|
[e09b70] | 404 | Shape::impl_ptr newImpl = Shape::impl_ptr(new OrShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
|
---|
[997784] | 405 | return Shape(newImpl);
|
---|
| 406 | }
|
---|
| 407 |
|
---|
| 408 | // NOT
|
---|
| 409 |
|
---|
| 410 | NotShape_impl::NotShape_impl(const Shape::impl_ptr &_arg) :
|
---|
| 411 | arg(_arg)
|
---|
| 412 | {}
|
---|
| 413 |
|
---|
| 414 | NotShape_impl::~NotShape_impl(){}
|
---|
| 415 |
|
---|
[735940] | 416 | bool NotShape_impl::isInside(const Vector &point) const{
|
---|
[997784] | 417 | return !arg->isInside(point);
|
---|
| 418 | }
|
---|
| 419 |
|
---|
[735940] | 420 | bool NotShape_impl::isOnSurface(const Vector &point) const{
|
---|
[5de9da] | 421 | return arg->isOnSurface(point);
|
---|
| 422 | }
|
---|
| 423 |
|
---|
[735940] | 424 | Vector NotShape_impl::getNormal(const Vector &point) const throw(NotOnSurfaceException){
|
---|
[b94634] | 425 | return -1.*arg->getNormal(point);
|
---|
[5de9da] | 426 | }
|
---|
| 427 |
|
---|
[6acc2f3] | 428 | Vector NotShape_impl::getCenter() const
|
---|
| 429 | {
|
---|
| 430 | return arg->getCenter();
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 | double NotShape_impl::getRadius() const
|
---|
| 434 | {
|
---|
| 435 | return std::numeric_limits<double>::infinity();
|
---|
| 436 | }
|
---|
| 437 |
|
---|
[c67c65] | 438 | double NotShape_impl::getVolume() const
|
---|
| 439 | {
|
---|
| 440 | // TODO
|
---|
| 441 | return -1.; //-arg->getVolume();
|
---|
| 442 | }
|
---|
| 443 |
|
---|
| 444 | double NotShape_impl::getSurfaceArea() const
|
---|
| 445 | {
|
---|
| 446 | // TODO
|
---|
| 447 | return -1.; // -arg->getSurfaceArea();
|
---|
| 448 | }
|
---|
| 449 |
|
---|
[735940] | 450 | LineSegmentSet NotShape_impl::getLineIntersections(const Line &line) const{
|
---|
[c6f395] | 451 | return invert(arg->getLineIntersections(line));
|
---|
| 452 | }
|
---|
| 453 |
|
---|
[b92e4a] | 454 | std::string NotShape_impl::toString() const{
|
---|
[955b91] | 455 | return std::string("!") + arg->toString();
|
---|
[cfda65] | 456 | }
|
---|
| 457 |
|
---|
[b92e4a] | 458 | enum ShapeType NotShape_impl::getType() const{
|
---|
| 459 | return CombinedType;
|
---|
| 460 | }
|
---|
| 461 |
|
---|
[9c1c89] | 462 | std::vector<Vector> NotShape_impl::getHomogeneousPointsOnSurface(const size_t N) const {
|
---|
[c5186e] | 463 | // surfaces are the same, only normal direction is different
|
---|
| 464 | return arg->getHomogeneousPointsOnSurface(N);
|
---|
| 465 | }
|
---|
| 466 |
|
---|
[5a8d61] | 467 | std::vector<Vector> NotShape_impl::getHomogeneousPointsInVolume(const size_t N) const {
|
---|
| 468 | ASSERT(0,
|
---|
| 469 | "NotShape_impl::getHomogeneousPointsInVolume() - not implemented.");
|
---|
| 470 | return std::vector<Vector>();
|
---|
| 471 | }
|
---|
| 472 |
|
---|
[997784] | 473 | Shape operator!(const Shape &arg){
|
---|
[e09b70] | 474 | Shape::impl_ptr newImpl = Shape::impl_ptr(new NotShape_impl(getShapeImpl(arg)));
|
---|
[997784] | 475 | return Shape(newImpl);
|
---|
| 476 | }
|
---|
[cfda65] | 477 |
|
---|
| 478 | /**************** global operations *********************************/
|
---|
[955b91] | 479 | std::ostream &operator<<(std::ostream &ost,const Shape &shape){
|
---|
[cfda65] | 480 | ost << shape.toString();
|
---|
| 481 | return ost;
|
---|
| 482 | }
|
---|