cisst-saw
Loading...
Searching...
No Matches
msh2BoundingBox.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3// ****************************************************************************
4//
5// Copyright (c) 2014, Seth Billings, Russell Taylor, Johns Hopkins University
6// All rights reserved.
7//
8// Redistribution and use in source and binary forms, with or without
9// modification, are permitted provided that the following conditions are
10// met:
11//
12// 1. Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14//
15// 2. Redistributions in binary form must reproduce the above copyright
16// notice, this list of conditions and the following disclaimer in the
17// documentation and/or other materials provided with the distribution.
18//
19// 3. Neither the name of the copyright holder nor the names of its
20// contributors may be used to endorse or promote products derived from
21// this software without specific prior written permission.
22//
23// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34//
35// ****************************************************************************
36
37#ifndef _msh2BoundingBox_h
38#define _msh2BoundingBox_h
39
41
42// Always include last!
43#include <cisstMesh/mshExport.h>
44
46{
47 public:
50 //vct2 HalfExtents; // SDB
51 public:
52
53 //void ComputeHalfExtents();
54
55 vct2 Diagonal() const {return MaxCorner-MinCorner;};
56 double DiagonalLength() const {return Diagonal().Norm();};
57
58 vct2 MidPoint() const { return (MinCorner+MaxCorner)*0.5;};
59
60 msh2BoundingBox(const vct2& MinC, const vct2& MaxC )
61 : MinCorner(MinC), MaxCorner(MaxC)
62 {}; //{ ComputeHalfExtents(); };
63
65 : MinCorner(HUGE_VAL,HUGE_VAL), MaxCorner(-HUGE_VAL,-HUGE_VAL)
66 {}; //{ ComputeHalfExtents(); };
67
70 {}; //{ ComputeHalfExtents(); };
71
74 //HalfExtents=S.HalfExtents;
75 return *this; };
76
79 //HalfExtents.Assign(0.0,0.0,0.0);
80 return *this;};
81
84
86 { MinCorner -= dist; MaxCorner+= dist;
87 return *this;
88 };
89 //ComputeHalfExtents(); };
90
91 int Includes(const vct2& p, double dist=0.0) const
92 { if (p[0] +dist < MinCorner[0]) return 0;
93 if (p[1] +dist < MinCorner[1]) return 0;
94 //if (p[2] +dist < MinCorner[2]) return 0;
95 if (p[0] -dist > MaxCorner[0]) return 0;
96 if (p[1] -dist > MaxCorner[1]) return 0;
97 //if (p[2] -dist > MaxCorner[2]) return 0;
98 return 1; // point is within distance "dist" of this bounding box
99 };
100
101 int Includes(const msh2BoundingBox& B, double dist=0.0) const
102 { return Includes(B.MinCorner,dist)&&Includes(B.MaxCorner,dist);
103 };
104};
105
106#endif
msh2BoundingBox(const vct2 &MinC, const vct2 &MaxC)
Definition msh2BoundingBox.h:60
msh2BoundingBox(const msh2BoundingBox &S)
Definition msh2BoundingBox.h:68
int Includes(const msh2BoundingBox &B, double dist=0.0) const
Definition msh2BoundingBox.h:101
vct2 MinCorner
Definition msh2BoundingBox.h:48
msh2BoundingBox()
Definition msh2BoundingBox.h:64
vct2 Diagonal() const
Definition msh2BoundingBox.h:55
msh2BoundingBox & EnlargeBy(double dist)
Definition msh2BoundingBox.h:85
double DiagonalLength() const
Definition msh2BoundingBox.h:56
msh2BoundingBox & Include(const vct2 &V)
vct2 MidPoint() const
Definition msh2BoundingBox.h:58
msh2BoundingBox & operator=(const vct2 &V)
Definition msh2BoundingBox.h:77
vct2 MaxCorner
Definition msh2BoundingBox.h:49
int Includes(const vct2 &p, double dist=0.0) const
Definition msh2BoundingBox.h:91
msh2BoundingBox & Include(const msh2BoundingBox &him)
msh2BoundingBox & operator=(const msh2BoundingBox &S)
Definition msh2BoundingBox.h:72
#define CISST_EXPORT
Definition cmnExportMacros.h:50
Macros to export the symbols of cisstMesh (in a Dll).
Typedef for fixed size vectors.
vctFixedSizeVector< double, 2 > vct2
Definition vctFixedSizeVectorTypes.h:41