Example #1
0
    NumLibSpatialFunctionQuad() :
        _geometric_size(10.0), _number_of_subdivisions_per_direction(10),
        _msh(MeshLib::MeshGenerator::generateRegularQuadMesh(_geometric_size, _number_of_subdivisions_per_direction)),
        _project_name("test"), _mshNodesSearcher(*_msh), _ply0(nullptr)
    {
        // create geometry
        std::vector<GeoLib::Point*>* pnts (new std::vector<GeoLib::Point*>);
        pnts->push_back(new GeoLib::Point(0.0, 0.0, 0.0));
        pnts->push_back(new GeoLib::Point(_geometric_size, 0.0, 0.0));
        pnts->push_back(new GeoLib::Point(_geometric_size, _geometric_size, 0.0));
        pnts->push_back(new GeoLib::Point(0.0, _geometric_size, 0.0));

        std::vector<GeoLib::Polyline*>* plys (new std::vector<GeoLib::Polyline*>);
        _ply0 = new GeoLib::Polyline(*pnts);
        _ply0->addPoint(0);
        _ply0->addPoint(1);
        plys->push_back(_ply0);

        GeoLib::Polyline* ply1 = new GeoLib::Polyline(*pnts);
        ply1->addPoint(0);
        ply1->addPoint(1);
        ply1->addPoint(2);
        ply1->addPoint(3);
        ply1->addPoint(0);
        plys->push_back(ply1);

        std::vector<GeoLib::Surface*>* sfcs (new std::vector<GeoLib::Surface*>);
        _sfc1 = GeoLib::Surface::createSurface(*ply1);
        sfcs->push_back(_sfc1);

        _geo_objs.addPointVec(pnts,_project_name);
        _geo_objs.addPolylineVec(plys, _project_name);
        _geo_objs.addSurfaceVec(sfcs, _project_name);
    }
TEST(GeoLib, GEOObjectsMergePointsAndPolylines)
{
	GeoLib::GEOObjects geo_objs;
	std::vector<std::string> names;

	// *** insert points to vector
	std::vector<GeoLib::Point*> *pnts(new std::vector<GeoLib::Point*>);
	pnts->reserve(4);
	pnts->push_back(new GeoLib::Point(0.0,0.0,0.0));
	pnts->push_back(new GeoLib::Point(1.0,0.0,0.0));
	pnts->push_back(new GeoLib::Point(1.0,1.0,0.0));
	pnts->push_back(new GeoLib::Point(0.0,1.0,0.0));

	std::string geometry_0("GeometryWithPntsAndPolyline");
	geo_objs.addPointVec(pnts, geometry_0, nullptr, std::numeric_limits<double>::epsilon());

	// *** insert polyline
	GeoLib::Polyline* ply(new GeoLib::Polyline(*geo_objs.getPointVec(geometry_0)));
	ply->addPoint(0);
	ply->addPoint(1);
	ply->addPoint(2);
	ply->addPoint(3);
	ply->addPoint(0);
	std::vector<GeoLib::Polyline*> *plys(new std::vector<GeoLib::Polyline*>);
	plys->push_back(ply);
	geo_objs.addPolylineVec(plys, geometry_0, nullptr);
	names.push_back(geometry_0);

	// *** insert set of points number
	GeoLib::Point shift (0.0,0.0,0.0);
	names.push_back("PointSet0");
	createSetOfTestPointsAndAssociatedNames(geo_objs, names[1], shift);

	// *** merge geometries
	std::string merged_geometries_name("MergedQuadGeoAndPointSet");
	geo_objs.mergeGeometries(names, merged_geometries_name);

	std::vector<GeoLib::Polyline*> const* const polylines =
		geo_objs.getPolylineVec(merged_geometries_name);

	ASSERT_TRUE(polylines != nullptr);
	ASSERT_EQ(polylines->size(), 1u);
}
Example #3
0
	NumLibDistributionHex() :
		_geometric_size(10.0), _number_of_subdivisions_per_direction(10),
		_msh(MeshLib::MeshGenerator::generateRegularHexMesh(_geometric_size, _number_of_subdivisions_per_direction)),
		_project_name("test"),
		_mshNodesSearcher(*_msh,MeshGeoToolsLib::SearchLength()),
		_ply0(nullptr)
	{
		// create geometry
		std::vector<GeoLib::Point*>* pnts (new std::vector<GeoLib::Point*>);
		pnts->push_back(new GeoLib::Point(0.0, 0.0, 0.0));
		pnts->push_back(new GeoLib::Point(_geometric_size, 0.0, 0.0));
		pnts->push_back(new GeoLib::Point(_geometric_size, _geometric_size, 0.0));
		pnts->push_back(new GeoLib::Point(0.0, _geometric_size, 0.0));
		pnts->push_back(new GeoLib::Point(0.0, 0.0, _geometric_size));
		pnts->push_back(new GeoLib::Point(_geometric_size, 0.0, _geometric_size));
		pnts->push_back(new GeoLib::Point(_geometric_size, _geometric_size, _geometric_size));
		pnts->push_back(new GeoLib::Point(0.0, _geometric_size, _geometric_size));

		std::vector<GeoLib::Polyline*>* plys (new std::vector<GeoLib::Polyline*>);
		_ply0 = new GeoLib::Polyline(*pnts); // vertical polyline
		_ply0->addPoint(0);
		_ply0->addPoint(4);
		plys->push_back(_ply0);
		GeoLib::Polyline* ply1 = new GeoLib::Polyline(*pnts); // polygon for left surface
		ply1->addPoint(0);
		ply1->addPoint(3);
		ply1->addPoint(7);
		ply1->addPoint(4);
		ply1->addPoint(0);
		plys->push_back(ply1);

		std::vector<GeoLib::Surface*>* sfcs (new std::vector<GeoLib::Surface*>);
		_sfc1 = GeoLib::Surface::createSurface(*ply1);
		sfcs->push_back(_sfc1);

		_geo_objs.addPointVec(pnts,_project_name);
		_geo_objs.addPolylineVec(plys, _project_name);
		_geo_objs.addSurfaceVec(sfcs, _project_name);
	}