-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geometry improvements #4221
Merged
Merged
Geometry improvements #4221
Changes from 13 commits
Commits
Show all changes
90 commits
Select commit
Hold shift + click to select a range
cc3a0b7
Polygon3d class with various useful methods (area etc). join method t…
ggartside b160f4b
Fnishes joinAll for Polygon3d. Added uniut test to repro issue 1614 a…
ggartside c8b56ff
Some basic Polygon3d unit tests in Geometry
ggartside 00f711b
Merge branch 'develop' into Geometry_Improvements
ggartside 5d1d00f
Changed the names of class methods for Polygon3d to match naming con…
ggartside 2df7b7e
Added joinAllPolygons method that takes Point3dVectors as arguments a…
ggartside 08b8946
Fixes an accidenmtal compile error
ggartside 784f028
Fixes a compile error reported in the pull request
ggartside f2b8d95
Fixing cppcheck/clang format issues
ggartside 3ae5b31
clang-format (with clang-format-12)
jmarrec 5550a1d
Fix some cppcheck errors
jmarrec ea25e0e
These are reported as cppcheck style warnings (unused variables). Con…
jmarrec 78c96eb
Renamed more methods to conform to coding standards (removed get prefix)
ggartside ced8117
joinAllPolygons was broken by a rename
ggartside 8b86198
Update src/utilities/geometry/Polygon.cpp to use size_t to avoid -Wer…
jmarrec 3ac5f46
adding joinAllWithBuffer
ggartside d234a47
Merge differences from recent pull
ggartside 3371648
Updated comments, added new Polygon3d constructor. Hoping thios one g…
ggartside e004637
Merge remote-tracking branch 'origin/develop' into Geometry_Improvements
jmarrec 15db807
Lint geometry_improvements and use const refs + rename to NewallVector
jmarrec 5f7742b
Merge pull request #4238 from NREL/geometry_improvements_mod
ggartside d2a075f
Adds method removeSpikesEx. This method uses buffer to shrink and exp…
ggartside 362bb8d
Merges joinAllWithBuffer branch (2527)
ggartside dca4325
Removes unused variables that are causing buildind fails
ggartside 8b5e98a
One last effort to fix these warnings
ggartside 212aea6
Added RemoveSpikesAndOverlaps test to verify removeSpikes fixes issue…
ggartside 9d3b85f
Suppress cppcheck warnings
jmarrec 947ef2e
Fix build error. The OSM file(s) referenced isn't in source control t…
jmarrec b68c10a
Fix build error in Intersection_GTest due to unused variables
jmarrec 51d5648
Fix more issues in Space_GTest
jmarrec 9dfc54a
Give an example of how to register and use test OSM(s) for use in test.
jmarrec 94f4521
clang format [chore]
jmarrec fe52006
Merge remote-tracking branch 'upstream/develop' into Geometry_Improve…
jmarrec d7ff466
Adds stripped down test for removing spikes where process was stuck i…
ggartside 7c2cb9a
Added overlap method to Polygon3d. Created Polygon3d_overlap unit test
ggartside 1553650
Create example of selectively adding tests for windows only
kbenne ac2580c
Adds a unit test for calculating exposed perimeter
ggartside 7060587
Adds exterior perimeter to Building and space
ggartside b19f89d
Renamed Space.exposedPerimeter added call to ExposedPerimeter test
ggartside 4d95d0f
Using unused variable result2
ggartside 82ee291
Merge branch 'Geometry_Improvements' of https://github.com/NREL/OpenS…
ggartside 260901d
Polygon.overlap, Building.exteriorPerimeter, Space.exposedPerimeter, …
ggartside c6da5c5
Adds a test to repro 1683, adds a test to repro 3982, ensures all Geo…
ggartside 8e3acb3
Removed surface shattering test as it is not in the current scope
ggartside d52f56f
(Hopefully) removed warnings that translate into errors
ggartside d9e2a59
Exzclude two tests that rely on model files (one takes 16 minutes to …
ggartside 6785082
clang-format changes
ggartside 08e7d19
Added unit test for 3982 - am not getting any triangulated surfaces b…
ggartside d01ea5f
Unit test for issue 2560, changes to Geometry.i
ggartside 0e025e9
Test for issue 3982
ggartside 1e00fee
Adds unit test for issue 2560
ggartside 480971b
Fixes to unit tests Issue_3982 and Surface_Intersect_ConcaveSurfaces …
ggartside e1e1429
Adjust BoundingBox intersection tolerance to 10mm from 1mm.
ggartside 78dc6d8
Renamed Polygon.hpp(cpp) -> Polygon3d.hpp(cpp)
ggartside b624855
Relaxes the tolerances for the area check in Surface::comupteIntersec…
ggartside dba1300
Merge branch 'GeometryShared' into Geometry_Improvements
ggartside 3d768ef
Fixes a build/merge issue
ggartside 05a44a9
clang!!!
ggartside feed490
Fixes issues that are causing Space_intersectSurfaces_degenerate2 to …
ggartside d17df78
Adds exposedPerimeter for Surface
ggartside b5657e1
Formatting corrections
ggartside 28f842a
Added ruby tests for the geometry improvements
ggartside 8474eb1
Changes geometry.i for polygon3d
ggartside 4f4c7fc
SOm enew tests some updated tests
ggartside d94a96c
Moved model files to resources/model, updated cmake file
ggartside 0f38555
Removing failing tests
ggartside bf23615
Fixes error in file name
ggartside c0e8704
Fixing a missing swig type optional Point3dVectorVector
ggartside 33ae7be
Merge branch 'develop' into Geometry_Improvements
jmarrec 5777ebb
Whitespace changes in ruby tests
jmarrec 8a4a5d3
Use correct name for `7-7_Windows_Complete.osm`
jmarrec ddf711b
Adjust and disable via commenting all saving of output (which is for …
jmarrec fb25ab9
Infer where to save, but also disable saving models in ruby test (thi…
jmarrec ef3201b
Some cleanup in comments
jmarrec 52daa4f
Space_Gtest: use EXPECT_ insert of ASSERT_ where possible
jmarrec 0ba9769
Space_Gtest: Remove macro code: enable tests on other than win32. For…
jmarrec 2f1fa96
change model version back down to 3.1.0 (or they won't load, 3.1.1 is…
jmarrec 284002c
Move disabled tests at end. surface shattering fails (logically), the…
jmarrec ac3d471
TEMPORARY: change jenkinsfile to point to the geometry_improvements b…
jmarrec c32ba21
output log file in a folder that exists.
jmarrec ad99016
Use const ref where possible, remove unused variables, break one-line…
jmarrec 0be4881
Change comments in Surface by adjusting units from mm2 to cm2 as I th…
jmarrec 8c07f5a
Use std::abs(float) instead of cstdlib abs(int)
jmarrec eed6954
Remove kyle's example of selectively adding test files in CMakeLists.txt
jmarrec f7ca31e
Merge pull request #4275 from NREL/Geometry_improvements_review
tijcolem 1063eb0
Added method to create a test model for perimeter calculations, rempv…
ggartside 7efb19f
Merge develop to branch
ggartside 26ee1fc
Resolved merge conflicts
ggartside fa14e8a
Fixed clan clanger (all clang did was remove an extra blank line from…
ggartside debd914
Added ruby scripts that create the floorplan_school model via the api
ggartside File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/*********************************************************************************************************************** | ||
* OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | ||
* following conditions are met: | ||
* | ||
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* | ||
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided with the distribution. | ||
* | ||
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products | ||
* derived from this software without specific prior written permission from the respective party. | ||
* | ||
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works | ||
* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior | ||
* written permission from Alliance for Sustainable Energy, LLC. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED | ||
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
***********************************************************************************************************************/ | ||
|
||
#include "Polygon.hpp" | ||
#include "Vector3d.hpp" | ||
#include "Geometry.hpp" | ||
|
||
namespace openstudio { | ||
|
||
Polygon3d::Polygon3d() {} | ||
|
||
Polygon3d::Polygon3d(Point3dVector outerPath) { | ||
for (auto p : outerPath) | ||
points.push_back(p); | ||
} | ||
|
||
/// <summary> | ||
/// Adds a point to the polygon perimeter | ||
/// </summary> | ||
/// <param name="point"></param> | ||
void Polygon3d::addPoint(Point3d& point) { | ||
points.push_back(point); | ||
} | ||
|
||
/// <summary> | ||
/// Sets the perimeter of the polygonb | ||
/// </summary> | ||
/// <param name="perimeter"></param> | ||
void Polygon3d::setOuterPath(Point3dVector outerPath) { | ||
points = outerPath; | ||
} | ||
|
||
Point3dVector Polygon3d::getOuterPath() const { | ||
return points; | ||
} | ||
|
||
Point3dVectorVector Polygon3d::getInnerPaths() const { | ||
return innerPaths; | ||
} | ||
|
||
/// <summary> | ||
/// Adds a hole to the polygon | ||
/// </summary> | ||
/// <param name="hole"></param> | ||
void Polygon3d::addHole(Point3dVector hole) { | ||
innerPaths.push_back(hole); | ||
} | ||
|
||
Vector3d Polygon3d::newellVector() { | ||
OptionalVector3d v = openstudio::getNewallVector(points); | ||
|
||
if (v) { | ||
return v.get(); | ||
} | ||
|
||
return Vector3d(); | ||
} | ||
|
||
Vector3d Polygon3d::outwardNormal() { | ||
return openstudio::getOutwardNormal(points).get(); | ||
} | ||
|
||
double Polygon3d::grossArea() { | ||
|
||
boost::optional<double> area = openstudio::getArea(points); | ||
if (area == boost::none) | ||
return 0; | ||
else | ||
return area.get(); | ||
return 0; | ||
} | ||
|
||
double Polygon3d::netArea() { | ||
|
||
double netArea = grossArea(); | ||
for (auto hole : innerPaths) { | ||
boost::optional<double> area = openstudio::getArea(hole); | ||
if (area != boost::none) netArea -= area.get(); | ||
} | ||
|
||
return netArea; | ||
} | ||
|
||
double Polygon3d::getPerimeter() { | ||
|
||
double perimeter = 0; | ||
for (size_t i = 0; i < points.size(); i++) { | ||
Point3d p1 = points[i]; | ||
Point3d p2 = points[(i + 1) % points.size()]; | ||
perimeter += openstudio::getDistance(p1, p2); | ||
} | ||
|
||
return perimeter; | ||
} | ||
|
||
bool Polygon3d::getIsClockwise() { | ||
OptionalVector3d normal = getOutwardNormal(points); | ||
if (normal == boost::none) | ||
return true; | ||
else | ||
return normal.get().z() > 0; | ||
} | ||
|
||
Point3d Polygon3d::getCentroid() { | ||
boost::optional p = openstudio::getCentroid(points); | ||
if (p == boost::none) | ||
return Point3d(); | ||
else | ||
return p.get(); | ||
} | ||
|
||
//bool Polygon3d::PointInPolygon(Point3d testPoint) { | ||
// return true; | ||
//} | ||
|
||
//typedef boost::geometry::model::polygon<BoostPoint> BoostPolygon; | ||
//typedef boost::geometry::model::d2::point_xy<double> BoostPoint; | ||
|
||
// TODO: I want to inlude all the boolean joining etc code here | ||
jmarrec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
} // namespace openstudio |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of these two is a typo