当前位置: 首页>>代码示例>>C++>>正文


C++ DBNetworkIF::CellPosition方法代码示例

本文整理汇总了C++中DBNetworkIF::CellPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ DBNetworkIF::CellPosition方法的具体用法?C++ DBNetworkIF::CellPosition怎么用?C++ DBNetworkIF::CellPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBNetworkIF的用法示例。


在下文中一共展示了DBNetworkIF::CellPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _CMDnetErosion

int _CMDnetErosion(DBObjData *netData, DBObjData *inData, DBObjData *weightData,
                   DBObjData *outData, DBFloat coeff, DBInt areaMult) {
    DBInt ret = DBSuccess, layerID, cellID, progress, maxProgress;
    DBFloat inValue, weight, outValue, *sumWeights;
    DBPosition pos;
    DBNetworkIF *netIF = new DBNetworkIF(netData);
    DBGridIF *inIF = new DBGridIF(inData);
    DBGridIF *outIF = new DBGridIF(outData);
    DBGridIF *weightIF = weightData != (DBObjData *) NULL ? new DBGridIF(weightData) : (DBGridIF *) NULL;
    DBObjRecord *inLayerRec, *outLayerRec, *weightLayerRec, *cellRec, *toCell;

    if ((sumWeights = (DBFloat *) calloc(netIF->CellNum(), sizeof(DBFloat))) == (DBFloat *) NULL) {
        CMmsgPrint(CMmsgSysError, "Memory allocation error in: %s %d", __FILE__, __LINE__);
        ret = DBFault;
        goto Stop;
    }

    layerID = 0;
    inLayerRec = inIF->Layer(layerID);

    outLayerRec = outIF->Layer(layerID);
    outIF->RenameLayer(outLayerRec, inLayerRec->Name());
    outValue = outIF->MissingValue(outLayerRec);
    for (pos.Row = 0; pos.Row < outIF->RowNum(); pos.Row++)
        for (pos.Col = 0; pos.Col < outIF->ColNum(); pos.Col++) outIF->Value(outLayerRec, pos, outValue);

    for (layerID = 1; layerID < inIF->LayerNum(); ++layerID) {
        inLayerRec = inIF->Layer(layerID);
        if ((outLayerRec = outIF->AddLayer(inLayerRec->Name())) == (DBObjRecord *) NULL) {
            ret = DBFault;
            goto Stop;
        }
        for (pos.Row = 0; pos.Row < outIF->RowNum(); pos.Row++)
            for (pos.Col = 0; pos.Col < outIF->ColNum(); pos.Col++) outIF->Value(outLayerRec, pos, outValue);
    }
    maxProgress = inIF->LayerNum() * netIF->CellNum();
    for (layerID = 0; layerID < inIF->LayerNum(); ++layerID) {
        inLayerRec = inIF->Layer(layerID);
        outLayerRec = outIF->Layer(layerID);
        if (weightIF != (DBGridIF *) NULL)
            weightLayerRec = weightIF->Layer(layerID % weightIF->LayerNum());
        for (cellID = 0; cellID < netIF->CellNum(); cellID++) {
            sumWeights[cellID] = 0.0;
            cellRec = netIF->Cell(cellID);
            if (inIF->Value(inLayerRec, netIF->Center(cellRec), &inValue) == false)
                outIF->Value(outLayerRec, netIF->CellPosition(cellRec), 0.0);
            else {
                if (weightIF != (DBGridIF *) NULL)
                    weight = weightIF->Value(weightLayerRec, netIF->Center(cellRec), &weight) == false ?
                             0.0 : weight * coeff;
                else weight = coeff;
                if (areaMult) weight = weight * netIF->CellArea(cellRec);
                sumWeights[cellID] = weight;
                outIF->Value(outLayerRec, netIF->CellPosition(cellRec), inValue * weight);
            }
        }

        for (cellID = netIF->CellNum() - 1; cellID >= 0; --cellID) {
            progress = layerID * netIF->CellNum() + (netIF->CellNum() - cellID);
            if (DBPause(progress * 100 / maxProgress)) goto Stop;
            cellRec = netIF->Cell(cellID);
            if ((toCell = netIF->ToCell(cellRec)) == (DBObjRecord *) NULL) continue;
            if (outIF->Value(outLayerRec, netIF->CellPosition(cellRec), &inValue) == false) continue;
            if (outIF->Value(outLayerRec, netIF->CellPosition(toCell), &outValue) == false) continue;

            sumWeights[toCell->RowID()] = sumWeights[toCell->RowID()] + weight;
            outIF->Value(outLayerRec, netIF->CellPosition(toCell), outValue + inValue);
        }
        outIF->RecalcStats(outLayerRec);
    }

    free(sumWeights);
    Stop:
    delete netIF;
    delete inIF;
    delete outIF;
    if (weightIF != (DBGridIF *) NULL) delete weightIF;
    return (ret);
}
开发者ID:bmfekete,项目名称:RGIS,代码行数:79,代码来源:CMDnetErosion.C

示例2: RGISEditAdjustNetworkCBK

void RGISEditAdjustNetworkCBK (Widget widget, RGISWorkspace *workspace,XmAnyCallbackStruct *callData)

	{
	DBInt vertex, vertexNum, dir, cell, cellNum, maxCellNum = 0;
	DBPosition pos0, pos1;
	DBCoordinate *vertexes;
	DBObjRecord *lineRec, **cellList = (DBObjRecord **) NULL;
	DBDataset *dataset = UIDataset ();
	DBObjData *netData = dataset->Data ();
	DBObjData *lineData = netData->LinkedData ();
	DBNetworkIF *netIF = new DBNetworkIF (netData);
	DBVLineIF *lineIF = new DBVLineIF (lineData);

	UIPauseDialogOpen ((char *) "Adjusting Networks");
	cellNum = 0;
	for (lineRec = lineIF->FirstItem ();lineRec != (DBObjRecord *) NULL; lineRec = lineIF->NextItem ())
		{
		UIPause (lineRec->RowID () * 100 / lineIF->ItemNum ());
		if (lineIF->ToNode (lineRec) == lineIF->FromNode (lineRec)) continue;
		if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return;
		if ((cellList [cellNum] = netIF->Cell (lineIF->FromCoord (lineRec))) == (DBObjRecord *) NULL)
			if((cellList [cellNum] = netIF->CellAdd (lineIF->FromCoord (lineRec))) != (DBObjRecord *) NULL) cellNum++;
		if ((vertexNum = lineIF->VertexNum (lineRec)) > 0)
			{
			vertexes = lineIF->Vertexes (lineRec);
			for (vertex = 0; vertex < vertexNum; ++vertex)
				{
				if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return;
				if ((cellList [cellNum] = netIF->Cell (vertexes [vertex])) == (DBObjRecord *) NULL)
					if((cellList [cellNum] = netIF->CellAdd (vertexes [vertex])) == (DBObjRecord *) NULL) continue;
				for (cell = 0;cell < cellNum;++cell) if (cellList [cell] == cellList [cellNum]) break;
				if (cell != cellNum) continue;
				cellNum++;
/*				if (cellNum > 1)
					{
					pos0 = netIF->CellPosition (cellList [cellNum - 2]);
					pos1 = netIF->CellPosition (cellList [cellNum - 1]);
					printf ("%5d   %3d %3d  %3d %3d\n",lineRec->RowID (),pos0.Col, pos0.Row, pos1.Col, pos1.Row);
					if ((abs (pos0.Row - pos1.Row) <= 1) && (abs (pos0.Col - pos1.Col) <= 1)) continue;
					if (abs (pos0.Row - pos1.Row) > abs (pos0.Col - pos1.Col))
						for (pos.Row = pos0.Row; pos.Row  != pos1.Row;
							  pos.Row = (pos0.Row < pos1.Row) ? pos.Row + 1 : pos.Row - 1)
							{
							pos.Col = pos0.Col + (DBUShort) ((((DBInt) pos.Row - (DBInt) pos0.Row) * ((DBInt) pos1.Col - (DBInt) pos0.Col)) / ((DBInt) pos1.Row - (DBInt) pos0.Row));
							if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return;
							if ((cellRec = netIF->Cell (pos)) != (DBObjRecord *) NULL)
								{
								cellList [cellNum] = cellList [cellNum - 1];
								cellList [cellNum - 1] = cellRec;
								cellNum++;
								}
							}
					else
						for (pos.Col = pos0.Col; pos.Col != pos1.Col;
							  pos.Col = (pos0.Col < pos1.Col) ? pos.Col + 1 : pos.Col - 1)
							{
							pos.Row = pos0.Row + (DBUShort) ((((DBInt) pos.Col - (DBInt) pos0.Col) * ((DBInt) pos1.Row - (DBInt) pos0.Row)) / ((DBInt) pos1.Col - (DBInt) pos0.Col));
							if ((cellList = _RGISReallocCellList (cellList,maxCellNum,cellNum + 1)) == (DBObjRecord **) NULL) return;
							if ((cellRec = netIF->Cell (pos)) != (DBObjRecord *) NULL)
								{
								cellList [cellNum] = cellList [cellNum - 1];
								cellList [cellNum - 1] = cellRec;
								cellNum++;
								}
							}
					}
*/				}
			}
 		for (cell = 0;cell < cellNum - 1;++cell)
 			{
			pos0 = netIF->CellPosition (cellList [cell]);
			pos1 = netIF->CellPosition (cellList [cell + 1]);
			if ((pos0.Col <  pos1.Col) && (pos0.Row == pos1.Row))	dir = DBNetDirE;
			else if ((pos0.Col <  pos1.Col) && (pos0.Row >  pos1.Row))	dir = DBNetDirSE;
			else if ((pos0.Col == pos1.Col) && (pos0.Row >  pos1.Row))	dir = DBNetDirS;
			else if ((pos0.Col >  pos1.Col) && (pos0.Row >  pos1.Row))	dir = DBNetDirSW;
			else if ((pos0.Col >  pos1.Col) && (pos0.Row == pos1.Row))	dir = DBNetDirW;
			else if ((pos0.Col >  pos1.Col) && (pos0.Row <  pos1.Row))	dir = DBNetDirNW;
			else if ((pos0.Col == pos1.Col) && (pos0.Row <  pos1.Row))	dir = DBNetDirN;
			else if ((pos0.Col <  pos1.Col) && (pos0.Row <  pos1.Row))	dir = DBNetDirNE;
//			printf ("%5d   %3d %3d  %3d %3d  %2x\n",lineRec->RowID (),pos0.Col, pos0.Row, pos1.Col, pos1.Row,dir);
			netIF->CellDirection (cellList [cell],dir);
			}
		}
	if (maxCellNum > 0) free (cellList);
	UIPauseDialogClose ();
	UIPauseDialogOpen ((char *) "Building Networks");
//	netIF->Build ();
	UIPauseDialogClose ();
	}
开发者ID:bandi13,项目名称:RGIS,代码行数:90,代码来源:RGISEditNet.C

示例3: _CMDnetTransfer

int _CMDnetTransfer(DBObjData *netData,
                    DBObjData *inData,
                    DBObjData *weightData,
                    DBObjData *outData,
                    DBFloat coeff,
                    DBObjData *coeffData,
                    DBObjData *QData,
                    DBObjData *HLData,
                    DBFloat umax,
                    DBFloat ksat,
                    DBInt areaMult) {
    DBInt ret = DBSuccess, layerID, cellID, progress, maxProgress;
    DBFloat inValue, weight, outValue, *sumWeights, kCoeff, q, hl, Conc, Uptake, Vf;
    DBPosition pos;
    DBNetworkIF *netIF = new DBNetworkIF(netData);
    DBGridIF *inIF = new DBGridIF(inData);
    DBGridIF *outIF = new DBGridIF(outData);
    DBGridIF *weightIF = weightData != (DBObjData *) NULL ? new DBGridIF(weightData) : (DBGridIF *) NULL;
    DBGridIF *coeffIF = coeffData != (DBObjData *) NULL ? new DBGridIF(coeffData) : (DBGridIF *) NULL;
    DBGridIF *Q_IF = QData != (DBObjData *) NULL ? new DBGridIF(QData) : (DBGridIF *) NULL;
    DBGridIF *HL_IF = HLData != (DBObjData *) NULL ? new DBGridIF(HLData) : (DBGridIF *) NULL;
    DBObjRecord *inLayerRec, *outLayerRec, *weightLayerRec, *coeffLayerRec, *Q_LayerRec, *HL_LayerRec, *cellRec, *toCell;
    DBCoordinate coord;


    if ((sumWeights = (DBFloat *) calloc(netIF->CellNum(), sizeof(DBFloat))) == (DBFloat *) NULL) {
        CMmsgPrint(CMmsgSysError, "Memory allocation error in: %s %d", __FILE__, __LINE__);
        ret = DBFault;
        goto Stop;
    }

    layerID = 0;
    inLayerRec = inIF->Layer(layerID);

    outLayerRec = outIF->Layer(layerID);
    outIF->RenameLayer(outLayerRec, inLayerRec->Name());
    outValue = outIF->MissingValue(outLayerRec);
    for (pos.Row = 0; pos.Row < outIF->RowNum(); pos.Row++)
        for (pos.Col = 0; pos.Col < outIF->ColNum(); pos.Col++) outIF->Value(outLayerRec, pos, outValue);

    for (layerID = 1; layerID < inIF->LayerNum(); ++layerID) {
        inLayerRec = inIF->Layer(layerID);
        if ((outLayerRec = outIF->AddLayer(inLayerRec->Name())) == (DBObjRecord *) NULL) {
            ret = DBFault;
            goto Stop;
        }
        for (pos.Row = 0; pos.Row < outIF->RowNum(); pos.Row++)
            for (pos.Col = 0; pos.Col < outIF->ColNum(); pos.Col++) outIF->Value(outLayerRec, pos, outValue);
    }
    maxProgress = inIF->LayerNum() * netIF->CellNum();
    for (layerID = 0; layerID < inIF->LayerNum(); ++layerID) {
        inLayerRec = inIF->Layer(layerID);
        outLayerRec = outIF->Layer(layerID);
        if (weightIF != (DBGridIF *) NULL)
            weightLayerRec = weightIF->Layer(layerID % weightIF->LayerNum());
        if (coeffIF != (DBGridIF *) NULL)
            coeffLayerRec = coeffIF->Layer(layerID % coeffIF->LayerNum());
        if (Q_IF != (DBGridIF *) NULL)
            Q_LayerRec = Q_IF->Layer(layerID % Q_IF->LayerNum());
        if (HL_IF != (DBGridIF *) NULL)
            HL_LayerRec = HL_IF->Layer(layerID % HL_IF->LayerNum());

        for (cellID = 0; cellID < netIF->CellNum(); cellID++) {
            sumWeights[cellID] = 0.0;
            cellRec = netIF->Cell(cellID);
            coord = netIF->Center(cellRec);
            if (inIF->Value(inLayerRec, coord, &inValue) == false)
                outIF->Value(outLayerRec, netIF->CellPosition(cellRec), 0.0);
            else {
                if (weightIF != (DBGridIF *) NULL)
                    weight = weightIF->Value(weightLayerRec, coord, &weight) == false ?
                             0.0 : weight * coeff;
                else weight = coeff;

                if (areaMult) weight = weight * netIF->CellArea(cellRec);
                sumWeights[cellID] = weight;
                outIF->Value(outLayerRec, netIF->CellPosition(cellRec), inValue * weight);
            }
        }

        for (cellID = netIF->CellNum() - 1; cellID >= 0; --cellID) {
            progress = layerID * netIF->CellNum() + (netIF->CellNum() - cellID);
            if (DBPause(progress * 100 / maxProgress)) goto Stop;
            cellRec = netIF->Cell(cellID);
            coord = netIF->Center(cellRec);
            if ((toCell = netIF->ToCell(cellRec)) == (DBObjRecord *) NULL) continue;
            if (outIF->Value(outLayerRec, netIF->CellPosition(cellRec), &inValue) == false) continue;
            if (outIF->Value(outLayerRec, netIF->CellPosition(toCell), &outValue) == false) continue;

            sumWeights[toCell->RowID()] = sumWeights[toCell->RowID()] + weight;


            if (coeffIF != (DBGridIF *) NULL) {
                if (coeffIF->Value(coeffLayerRec, netIF->Center(cellRec), &kCoeff) == false) kCoeff = 1.0;
            }
            else {
                if (((Q_IF == (DBGridIF *) NULL) || (Q_IF->Value(Q_LayerRec, netIF->Center(cellRec), &q) == false)) ||
                        ((HL_IF == (DBGridIF *) NULL) ||
                         (HL_IF->Value(HL_LayerRec, netIF->Center(cellRec), &hl) == false)) ||
                        (umax == 0) || (ksat == 0))
//.........这里部分代码省略.........
开发者ID:bmfekete,项目名称:RGIS,代码行数:101,代码来源:CMDnetTransfer.C


注:本文中的DBNetworkIF::CellPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。