//--------------------------------------------------------- bool CPolygon_Vertex_Check::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( Parameters("CHECKED")->asShapes() && Parameters("CHECKED")->asShapes() != pPolygons ) { CSG_Shapes *pCopy = Parameters("CHECKED")->asShapes(); pCopy->Create(*pPolygons); pCopy->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("checked"))); pPolygons = pCopy; } if( (m_pAdded = Parameters("ADDED")->asShapes()) != NULL ) { m_pAdded->Create(SHAPE_TYPE_Point, _TL("Added")); } double Epsilon = Parameters("EPSILON")->asDouble(); //----------------------------------------------------- for(int iPolygon=0; iPolygon<pPolygons->Get_Count()-1 && Set_Progress(iPolygon, pPolygons->Get_Count()-1); iPolygon++) { CSG_Shape_Polygon *pA = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); for(int jPolygon=iPolygon+1; jPolygon<pPolygons->Get_Count() && Process_Get_Okay(); jPolygon++) { CSG_Shape_Polygon *pB = (CSG_Shape_Polygon *)pPolygons->Get_Shape(jPolygon); for(int iPart=0; iPart<pA->Get_Part_Count() && Process_Get_Okay(); iPart++) { for(int jPart=0; jPart<pB->Get_Part_Count() && Process_Get_Okay(); jPart++) { if( pA->Get_Part(iPart)->Get_Extent().Intersects(pB->Get_Part(jPart)->Get_Extent()) ) { Check_Vertices(pA->Get_Part(iPart), pB->Get_Part(jPart), Epsilon); Check_Vertices(pB->Get_Part(jPart), pA->Get_Part(iPart), Epsilon); } } } } } //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- bool CPolygon_Shared_Edges::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); m_Field = Parameters("ATTRIBUTE")->asInt(); m_pEdges = Parameters("EDGES")->asShapes(); m_pEdges->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Edges"))); m_pEdges->Add_Field("ID_A", m_Field < 0 ? SG_DATATYPE_Int : pPolygons->Get_Field_Type(m_Field)); m_pEdges->Add_Field("ID_B", m_Field < 0 ? SG_DATATYPE_Int : pPolygons->Get_Field_Type(m_Field)); // m_pNodes = Parameters("NODES")->asShapes(); // m_pNodes->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Nodes"))); // m_pNodes->Add_Field("ID", SG_DATATYPE_Int); bool bVertices = Parameters("VERTICES")->asBool (); double Epsilon = Parameters("EPSILON" )->asDouble(); int iPolygon, nAdded = 0, nRemoved = 0; //----------------------------------------------------- if( bVertices ) { for(iPolygon=0; iPolygon<pPolygons->Get_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); for(int iPart=0; iPart<pPolygon->Get_Part_Count() && Process_Get_Okay(); iPart++) { CSG_Shape_Part *pPart = pPolygon->Get_Part(iPart); CSG_Point A = pPart->Get_Point(pPart->Get_Count() - 1); if( A != pPart->Get_Point(0) ) { pPart->Add_Point(A); } for(int iPoint=pPart->Get_Count()-2; iPoint>=0; iPoint--) { CSG_Point B = A; A = pPart->Get_Point(iPoint); if( A == B ) { pPart->Del_Point(iPoint + 1); nRemoved--; } } } } } //----------------------------------------------------- for(iPolygon=0; iPolygon<pPolygons->Get_Count()-1 && Set_Progress(iPolygon, pPolygons->Get_Count()-1); iPolygon++) { CSG_Shape_Polygon *pA = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); for(int jPolygon=iPolygon+1; jPolygon<pPolygons->Get_Count() && Process_Get_Okay(); jPolygon++) { CSG_Shape_Polygon *pB = (CSG_Shape_Polygon *)pPolygons->Get_Shape(jPolygon); for(int iPart=0; iPart<pA->Get_Part_Count() && Process_Get_Okay(); iPart++) { for(int jPart=0; jPart<pB->Get_Part_Count() && Process_Get_Okay(); jPart++) { if( pA->Get_Part(iPart)->Get_Extent().Intersects(pB->Get_Part(jPart)->Get_Extent()) ) { if( bVertices ) { nAdded += Check_Vertices(pA->Get_Part(iPart), pB->Get_Part(jPart), Epsilon); nAdded += Check_Vertices(pB->Get_Part(jPart), pA->Get_Part(iPart), Epsilon); } Get_Shared_Edges(pA->Get_Part(iPart), pB->Get_Part(jPart), Epsilon); } } } } } //----------------------------------------------------- if( Parameters("DOUBLE")->asBool() ) { for(int iEdge=0, nEdges=m_pEdges->Get_Count(); iEdge<nEdges && Set_Progress(iEdge, nEdges); iEdge++) { CSG_Shape *pA = m_pEdges->Get_Shape(iEdge); CSG_Shape *pB = m_pEdges->Add_Shape(pA); *(pB->Get_Value(0)) = *(pA->Get_Value(1)); *(pB->Get_Value(1)) = *(pA->Get_Value(0)); } } //----------------------------------------------------- if( nAdded > 0 || nRemoved > 0 ) { Message_Add(CSG_String::Format(SG_T("\n%s: %d %s, %d %s\n"), _TL("Vertices"), nAdded , _TL("added" ), nRemoved, _TL("removed") ), false); DataObject_Update(pPolygons); } return( true ); }