//--------------------------------------------------------- bool CTIN_From_Shapes::On_Execute(void) { CSG_TIN *pTIN; CSG_Shapes *pShapes; pShapes = Parameters("SHAPES") ->asShapes(); pTIN = Parameters("TIN") ->asTIN(); return( pTIN->Create(pShapes) ); }
//--------------------------------------------------------- bool CTIN_From_Grid_Specific_Points::On_Execute(void) { bool bResult; int x, y, i; CSG_TIN *pTIN; CSG_Grid *pGrid, Grid; CSG_Parameter_Grid_List *pValues; CSG_Shape *pPoint; CSG_Shapes Points; //----------------------------------------------------- pGrid = Parameters("GRID")->asGrid(); Grid.Create(pGrid, SG_DATATYPE_Byte); //----------------------------------------------------- switch( Parameters("METHOD")->asInt() ) { default: bResult = false; break; case 0: bResult = Get_MarkHighestNB (&Grid, pGrid); break; case 1: bResult = Get_OppositeNB (&Grid, pGrid, Parameters("HIGH")->asInt()); break; case 2: bResult = Get_FlowDirection (&Grid, pGrid, (int)Parameters("FLOW")->asRange()->Get_LoVal(), (int)Parameters("FLOW")->asRange()->Get_HiVal() ); break; case 3: bResult = Get_FlowDirection2(&Grid, pGrid, (int)Parameters("FLOW")->asRange()->Get_HiVal() ); break; case 4: bResult = Get_Peucker (&Grid, pGrid, Parameters("PEUCKER")->asDouble()); break; } //----------------------------------------------------- if( bResult ) { pValues = Parameters("VALUES")->asGridList(); Points.Create(SHAPE_TYPE_Point); Points.Add_Field(_TL("VALUE"), SG_DATATYPE_Double); for(i=0; i<pValues->Get_Count(); i++) { Points.Add_Field(pValues->asGrid(i)->Get_Name(), SG_DATATYPE_Double); } for(y=0; y<Get_NY() && Set_Progress(y, Get_NY()); y++) { for(x=0; x<Get_NX(); x++) { if( Grid.asInt(x, y) != 0 ) { pPoint = Points.Add_Shape(); pPoint->Add_Point( Get_XMin() + Get_Cellsize() * x, Get_YMin() + Get_Cellsize() * y ); pPoint->Set_Value(0, pGrid->asDouble(x, y)); for(i=0; i<pValues->Get_Count(); i++) { pPoint->Set_Value(1 + i, pValues->asGrid(i)->asDouble(x, y)); } } } } //------------------------------------------------- if( Points.Get_Count() >= 3 ) { pTIN = Parameters("TIN")->asTIN(); pTIN->Create(&Points); pTIN->Set_Name(pGrid->Get_Name()); } } return( bResult ); }