Example #1
0
	static bool IsGoodSolutionSequence (const CellVector &theCellVector){
		LogicAssert (true == IsGoodSchemaSequence (theCellVector));
		bool rit = true;
		for (CellValue aCellValue = 0; aCellValue < kDim && rit; ++aCellValue){
			const size_t aNumValue = std::count_if (theCellVector.begin (), theCellVector.end () , SCountHelper (aCellValue + 1));
			/*
			const size_t aNumValue = std::count_if (theCellVector.begin (), theCellVector.end () , [aCellValue] (const Cell * theIter){
				LogicAssert (true == IsGoodPtr (theIter));
				return theIter->GetValue () == aCellValue + 1;
			});
			*/
			rit = (1 == aNumValue);
		}
		return rit;
	}
Example #2
0
	static bool IsGoodSchemaSequenceAdvanced (const CellVector &theCellVector){
		size_t aNumTotal = 0;
		bool rit = true;
		for (CellValue aCellValue = 0; aCellValue < (kDim + 1) && rit; ++aCellValue){
			const size_t aNumValue = std::count_if (theCellVector.begin (), theCellVector.end (), SCountHelper (aCellValue));
			/*
			const size_t aNumValue = std::count_if (theCellVector.begin (), theCellVector.end () , [aCellValue] (const Cell * theIter) -> bool{
				LogicAssert (true == IsGoodPtr (theIter));
				return theIter->GetValue () == aCellValue + 0;
			});
			*/
			aNumTotal += aNumValue;
			rit = ((1 == aNumValue) || (0 == aNumValue) || (0 == aCellValue));
		}
		return (kDim == aNumTotal) && rit;
	}
unsigned Qwt3D::tesselationSize(CellVector const& t)
{
	unsigned ret = 0;
	
	for (unsigned i=0; i!=t.size(); ++i)
		ret += t[i].size();
	
	return ret;
}
Example #4
0
	static std::size_t CountFree (const CellVector &theCellVector){
		return std::count_if (theCellVector.begin (), theCellVector.end (), MyCountFree);
	}
Example #5
0
	static bool IsAvailable (const CellVector &theCellVector, const CellValue theCellValue){
        LogicAssert ((theCellValue >= 1) && (theCellValue <= 9));

        const CellVector::const_iterator aIterResult = std::find_if (theCellVector.begin (), theCellVector.end () , SFindHelper (theCellValue));
        return  theCellVector.end () == aIterResult;
	}
Example #6
0
void VTKTool::dumpGridCell(const string filename, const CellVector cells)
{
    /*
        # vtk DataFile Version 3.0
        My unstructured Grid Example 2
        ASCII
        DATASET UNSTRUCTURED_GRID
        POINTS 27 float
        0 0 0
        1 0 0
        2 0 0
        0 1 0
        CELLS 11 60 // 11 groups, 60 point-entries related in all
        8 0 1 .. // 8 element, 9 entries
        4 1 2 3 4 // 4 element, 5 entries
        CELL_TYPE 11
        11 // voxel, need 8 defining elements
        11
        ..
        */
    ofstream out(filename.c_str());
    const unsigned int num(cells.size()); // number of cells

    // 1. Header
    out << "# vtk DataFile Version 3.0\n";
    out << "3D Occupancy Grid used by topomap\n";
    out << "ASCII\n";
    out << "DATASET UNSTRUCTURED_GRID\n";

    // 2. Tokens defining points
    out << "POINTS " << num*8 << " float" << endl; // each token has 8 defining points
    for (unsigned int i = 0; i<num; i++)
    {
        // token center positions
        float cx = cells[i].pose.get<0>();
        float cy = cells[i].pose.get<1>();
        float cz = cells[i].pose.get<2>();
        // offset, half window
        float hx = cells[i].len.get<0>()/2;
        float hy = cells[i].len.get<1>()/2;
        float hz = cells[i].len.get<2>()/2;
        // find 8 defining points of each token
        // page 9 of : http://www.vtk.org/VTK/img/file-formats.pdf
        // 0
        out << cx-hx << ' ' << cy-hy << ' ' << cz-hz << endl;
        // 1
        out << cx+hx << ' ' << cy-hy << ' ' << cz-hz << endl;
        // 2
        out << cx-hx << ' ' << cy+hy << ' ' << cz-hz << endl;
        // 3
        out << cx+hx << ' ' << cy+hy << ' ' << cz-hz << endl;
        // 4
        out << cx-hx << ' ' << cy-hy << ' ' << cz+hz << endl;
        // 5
        out << cx+hx << ' ' << cy-hy << ' ' << cz+hz << endl;
        // 6
        out << cx-hx << ' ' << cy+hy << ' ' << cz+hz << endl;
        // 7
        out << cx+hx << ' ' << cy+hy << ' ' << cz+hz << endl;
    }

    // 3. Indexing defining points for each cell
    out << "CELLS " << num << ' ' << num*9 << endl;
    for (unsigned int i = 0; i<num; i++)
    {
        out << "8 " << i*8 << ' ' << i*8+1 << ' ' << i*8+2 << ' ' << i*8+3 << ' '
            << i*8+4 << ' ' << i*8+5 << ' ' << i*8+6 << ' ' << i*8+7 << endl;
    }

    // 4. cell display type, here is VTK_VOXEL: 11
    out << "CELL_TYPES " << num << endl;
    for (unsigned int i = 0; i<num; i++)
        out << "11\n";

    out.close();
}