MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
GeometryIntersection< nDim_ >::CsgNode Class Reference
Collaboration diagram for GeometryIntersection< nDim_ >::CsgNode:
[legend]

Public Member Functions

 CsgNode (std::vector< CsgPolygon > _polygons)
 
 CsgNode ()
 
 ~CsgNode ()
 
void invert ()
 
std::vector< CsgPolygonclipPolygons (std::vector< CsgPolygon > _polygons)
 
void clipTo (CsgNode &bsp)
 
std::vector< CsgPolygonallPolygons ()
 
template<class T = void>
std::enable_if< nDim_==2, T >::type build (std::vector< CsgPolygon > _polygons)
 
template<class T = void>
std::enable_if< nDim_==3, T >::type build (std::vector< CsgPolygon > _polygons)
 

Public Attributes

CsgPlane plane
 
MBool planeValid
 
CsgNodefront
 
CsgNodeback
 
std::vector< CsgPolygonpolygons
 

Detailed Description

template<MInt nDim_>
class GeometryIntersection< nDim_ >::CsgNode

Definition at line 740 of file geometryintersection.h.

Constructor & Destructor Documentation

◆ CsgNode() [1/2]

template<MInt nDim_>
GeometryIntersection< nDim_ >::CsgNode::CsgNode ( std::vector< CsgPolygon _polygons)
inlineexplicit

Definition at line 748 of file geometryintersection.h.

748 {
749 planeValid = false;
750 front = nullptr;
751 back = nullptr;
752 polygons.clear();
753 this->build(_polygons);
754 }
std::enable_if< nDim_==2, T >::type build(std::vector< CsgPolygon > _polygons)
std::vector< CsgPolygon > polygons

◆ CsgNode() [2/2]

template<MInt nDim_>
GeometryIntersection< nDim_ >::CsgNode::CsgNode ( )
inline

Definition at line 756 of file geometryintersection.h.

756 {
757 planeValid = false;
758 front = nullptr;
759 back = nullptr;
760 polygons.clear();
761 }

◆ ~CsgNode()

template<MInt nDim_>
GeometryIntersection< nDim_ >::CsgNode::~CsgNode ( )
inline

Definition at line 763 of file geometryintersection.h.

763 {
764 this->polygons.clear();
765 delete this->front;
766 delete this->back;
767 }

Member Function Documentation

◆ allPolygons()

template<MInt nDim_>
std::vector< CsgPolygon > GeometryIntersection< nDim_ >::CsgNode::allPolygons ( )
inline

Definition at line 806 of file geometryintersection.h.

806 {
807 std::vector<CsgPolygon> _polygons(this->polygons);
808 if(this->front) {
809 std::vector<CsgPolygon> _polygons_front = this->front->allPolygons();
810 for(MInt i = 0; (unsigned)i < _polygons_front.size(); i++)
811 _polygons.push_back(_polygons_front[i]);
812 }
813 if(this->back) {
814 std::vector<CsgPolygon> _polygons_back = this->back->allPolygons();
815 for(MInt i = 0; (unsigned)i < _polygons_back.size(); i++)
816 _polygons.push_back(_polygons_back[i]);
817 }
818 return _polygons;
819 }
std::vector< CsgPolygon > allPolygons()
int32_t MInt
Definition: maiatypes.h:62

◆ build() [1/2]

template<MInt nDim_>
template<class T = void>
std::enable_if< nDim_==2, T >::type GeometryIntersection< nDim_ >::CsgNode::build ( std::vector< CsgPolygon _polygons)
inline

Definition at line 824 of file geometryintersection.h.

824 {
825 if(_polygons.empty()) return;
826 if(!planeValid) {
827 this->plane = _polygons[0].plane.clone();
828 planeValid = true;
829 }
830 std::vector<CsgPolygon> _front;
831 std::vector<CsgPolygon> _back;
832 this->plane.insertCoplanarPolygon(&_polygons[0], &this->polygons, &this->polygons);
833 for(MInt i = 1; (unsigned)i < _polygons.size(); i++) {
834 this->plane.splitPolygon(&_polygons[i], &this->polygons, &this->polygons, &_front, &_back);
835 }
836 if(!_front.empty()) {
837 if(!this->front) this->front = new CsgNode();
838 this->front->build(_front);
839 }
840 if(!_back.empty()) {
841 if(!this->back) this->back = new CsgNode();
842 this->back->build(_back);
843 }
844 }
std::enable_if< nDim_==2, T >::type splitPolygon(CsgPolygon *polygon, std::vector< CsgPolygon > *coplanarFront, std::vector< CsgPolygon > *coplanarBack, std::vector< CsgPolygon > *front, std::vector< CsgPolygon > *back)
void insertCoplanarPolygon(CsgPolygon *polygon, std::vector< CsgPolygon > *coplanarFront, std::vector< CsgPolygon > *coplanarBack)

◆ build() [2/2]

template<MInt nDim_>
template<class T = void>
std::enable_if< nDim_==3, T >::type GeometryIntersection< nDim_ >::CsgNode::build ( std::vector< CsgPolygon _polygons)
inline

Definition at line 846 of file geometryintersection.h.

846 {
847 if(_polygons.empty()) return;
848 std::vector<CsgPolygon> _front;
849 std::vector<CsgPolygon> _back;
850 MInt polygonStartIndex = 0;
851 if(!planeValid) {
852 this->plane = _polygons[0].plane.clone();
853 planeValid = true;
854 this->polygons.push_back(_polygons[0]);
855 polygonStartIndex = 1;
856 }
857 for(MInt i = polygonStartIndex; (unsigned)i < _polygons.size(); i++) {
858 this->plane.splitPolygon(&_polygons[i], &this->polygons, &this->polygons, &_front, &_back);
859 }
860 if(!_front.empty()) {
861 if(!this->front) this->front = new CsgNode();
862 this->front->build(_front);
863 }
864 if(!_back.empty()) {
865 if(!this->back) this->back = new CsgNode();
866 this->back->build(_back);
867 }
868 }

◆ clipPolygons()

template<MInt nDim_>
std::vector< CsgPolygon > GeometryIntersection< nDim_ >::CsgNode::clipPolygons ( std::vector< CsgPolygon _polygons)
inline

Definition at line 781 of file geometryintersection.h.

781 {
782 if(!planeValid) {
783 return _polygons;
784 }
785 std::vector<CsgPolygon> _front;
786 std::vector<CsgPolygon> _back;
787 for(MInt i = 0; (unsigned)i < _polygons.size(); i++) {
788 this->plane.splitPolygon(&_polygons[i], &_front, &_back, &_front, &_back);
789 }
790 if(this->front) _front = this->front->clipPolygons(_front);
791 if(this->back)
792 _back = this->back->clipPolygons(_back);
793 else
794 _back.clear();
795 for(MInt i = 0; (unsigned)i < _back.size(); i++)
796 _front.push_back(_back[i]);
797 return _front;
798 }
std::vector< CsgPolygon > clipPolygons(std::vector< CsgPolygon > _polygons)

◆ clipTo()

template<MInt nDim_>
void GeometryIntersection< nDim_ >::CsgNode::clipTo ( CsgNode bsp)
inline

Definition at line 800 of file geometryintersection.h.

800 {
801 this->polygons = bsp.clipPolygons(this->polygons);
802 if(this->front) this->front->clipTo(bsp);
803 if(this->back) this->back->clipTo(bsp);
804 }

◆ invert()

template<MInt nDim_>
void GeometryIntersection< nDim_ >::CsgNode::invert ( )
inline

Definition at line 769 of file geometryintersection.h.

769 {
770 for(MInt i = 0; (unsigned)i < this->polygons.size(); i++) {
771 this->polygons[i].flip();
772 }
773 this->plane.flip();
774 if(this->front) this->front->invert();
775 if(this->back) this->back->invert();
776 CsgNode* temp = this->front;
777 this->front = this->back;
778 this->back = temp;
779 }

Member Data Documentation

◆ back

template<MInt nDim_>
CsgNode* GeometryIntersection< nDim_ >::CsgNode::back

Definition at line 745 of file geometryintersection.h.

◆ front

template<MInt nDim_>
CsgNode* GeometryIntersection< nDim_ >::CsgNode::front

Definition at line 744 of file geometryintersection.h.

◆ plane

template<MInt nDim_>
CsgPlane GeometryIntersection< nDim_ >::CsgNode::plane

Definition at line 742 of file geometryintersection.h.

◆ planeValid

template<MInt nDim_>
MBool GeometryIntersection< nDim_ >::CsgNode::planeValid

Definition at line 743 of file geometryintersection.h.

◆ polygons

template<MInt nDim_>
std::vector<CsgPolygon> GeometryIntersection< nDim_ >::CsgNode::polygons

Definition at line 746 of file geometryintersection.h.


The documentation for this class was generated from the following file: