-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
117 additions
and
3 deletions.
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
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,50 @@ | ||
#include "xminkowski2d.h" | ||
#include "cf_xmlNode.h" | ||
#include "xshape2d_collector.h" | ||
|
||
#include "clipper_boolean.h" | ||
#include "boolean_timer.h" | ||
|
||
xminkowski2d::xminkowski2d() | ||
{} | ||
|
||
xminkowski2d::xminkowski2d(const cf_xmlNode& node) | ||
{ | ||
if(node.tag() != "minkowski2d")throw logic_error("Expected xml tag minkowski2d, but found " + node.tag()); | ||
set_transform(node); | ||
xshape2d_collector::collect_children(node,m_incl); | ||
|
||
if(m_incl.size() != 2) throw logic_error("Expected 2 parameters for minkowski2d, but got " + std::to_string(m_incl.size())); | ||
} | ||
|
||
|
||
xminkowski2d::~xminkowski2d() | ||
{} | ||
|
||
size_t xminkowski2d::nbool() | ||
{ | ||
size_t nbool = 0; | ||
for(auto i=m_incl.begin(); i!=m_incl.end(); i++) { | ||
std::shared_ptr<xshape2d> obj = *i; | ||
nbool += (obj->nbool()+1); | ||
} | ||
return nbool-1; | ||
} | ||
|
||
|
||
std::shared_ptr<clipper_profile> xminkowski2d::create_clipper_profile(const carve::math::Matrix& t) const | ||
{ | ||
std::shared_ptr<clipper_profile> a = m_incl[0]->create_clipper_profile(t*get_transform()); | ||
std::shared_ptr<clipper_profile> b_brush = m_incl[1]->create_clipper_profile(t*get_transform()); | ||
|
||
clipper_boolean csg; | ||
csg.minkowski_sum(a,b_brush); | ||
return csg.profile(); | ||
} | ||
|
||
std::shared_ptr<carve::mesh::MeshSet<3>> xminkowski2d::create_carve_mesh(const carve::math::Matrix& t) const | ||
{ | ||
std::shared_ptr<carve::mesh::MeshSet<3>> mesh; | ||
|
||
return mesh; | ||
} |
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,22 @@ | ||
#ifndef xminkowski2d_H | ||
#define xminkowski2d_H | ||
|
||
#include "xshape2d.h" | ||
|
||
class xminkowski2d : public xshape2d { | ||
public: | ||
xminkowski2d(); | ||
xminkowski2d(const cf_xmlNode& node); | ||
virtual ~xminkowski2d(); | ||
|
||
virtual size_t nbool(); | ||
|
||
std::shared_ptr<clipper_profile> create_clipper_profile(const carve::math::Matrix& t = carve::math::Matrix()) const; | ||
std::shared_ptr<carve::mesh::MeshSet<3>> create_carve_mesh(const carve::math::Matrix& t = carve::math::Matrix()) const; | ||
protected: | ||
|
||
private: | ||
std::vector<std::shared_ptr<xshape2d>> m_incl; | ||
}; | ||
|
||
#endif // xminkowski2d_H |