本文整理汇总了C++中GeometryPtr类的典型用法代码示例。如果您正苦于以下问题:C++ GeometryPtr类的具体用法?C++ GeometryPtr怎么用?C++ GeometryPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeometryPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildSphere
//////////////////////////////////////////////////////////////////////////
//! build a sphere
//////////////////////////////////////////////////////////////////////////
void buildSphere(void)
{
Real32 Radius(frand()*1.5+0.2);
Matrix m;
//create OpenSG mesh
GeometryPtr sphere;
NodePtr sphereNode = makeSphere(2, Radius);
sphere = GeometryPtr::dcast(sphereNode->getCore());
SimpleMaterialPtr sphere_mat = SimpleMaterial::create();
beginEditCP(sphere_mat);
sphere_mat->setAmbient(Color3f(0.0,0.0,0.0));
sphere_mat->setDiffuse(Color3f(0.0,0.0,1.0));
endEditCP(sphere_mat);
beginEditCP(sphere, Geometry::MaterialFieldMask);
sphere->setMaterial(sphere_mat);
endEditCP(sphere);
TransformPtr sphereTrans;
NodePtr sphereTransNode = makeCoredNode<Transform>(&sphereTrans);
m.setIdentity();
Real32 randX = frand()*10.0-5.0;
Real32 randY = frand()*10.0-5.0;
m.setTranslate(randX, randY, 10.0);
beginEditCP(sphereTrans, Transform::MatrixFieldMask);
sphereTrans->setMatrix(m);
endEditCP(sphereTrans);
//create ODE data
PhysicsBodyPtr sphereBody = PhysicsBody::create(physicsWorld);
beginEditCP(sphereBody, PhysicsBody::PositionFieldMask | PhysicsBody::AngularDampingFieldMask);
sphereBody->setPosition(Vec3f(randX, randY, 10.0));
sphereBody->setAngularDamping(0.0001);
endEditCP(sphereBody, PhysicsBody::PositionFieldMask | PhysicsBody::AngularDampingFieldMask);
sphereBody->setSphereMass(0.4,Radius);
PhysicsSphereGeomPtr sphereGeom = PhysicsSphereGeom::create();
beginEditCP(sphereGeom, PhysicsSphereGeom::BodyFieldMask | PhysicsSphereGeom::SpaceFieldMask | PhysicsSphereGeom::RadiusFieldMask | PhysicsSphereGeom::CategoryBitsFieldMask);
sphereGeom->setBody(sphereBody);
sphereGeom->setSpace(physicsSpace);
sphereGeom->setRadius(Radius);
sphereGeom->setCategoryBits(SphereCategory);
endEditCP(sphereGeom, PhysicsSphereGeom::BodyFieldMask | PhysicsSphereGeom::SpaceFieldMask | PhysicsSphereGeom::RadiusFieldMask | PhysicsSphereGeom::CategoryBitsFieldMask);
//add attachments
beginEditCP(sphereNode, Node::AttachmentsFieldMask);
sphereNode->addAttachment(sphereGeom);
endEditCP(sphereNode);
beginEditCP(sphereTransNode, Node::AttachmentsFieldMask | Node::ChildrenFieldMask);
sphereTransNode->addAttachment(sphereBody);
sphereTransNode->addChild(sphereNode);
endEditCP(sphereTransNode);
//add to SceneGraph
beginEditCP(spaceGroupNode, Node::ChildrenFieldMask);
spaceGroupNode->addChild(sphereTransNode);
endEditCP(spaceGroupNode);
}
示例2: coord
void object::test<10>()
{
geos::geom::Coordinate coord(x_, y_, z_);
CoordArrayPtr sequence = new geos::geom::CoordinateArraySequence();
ensure( "sequence is null pointer.", sequence != 0 );
sequence->add(coord);
PointPtr pt = factory_.createPoint(sequence);
ensure( "createPoint() returned null pointer.", pt != 0 );
ensure( "createPoint() returned empty point.", !pt->isEmpty() );
ensure( pt->isSimple() );
ensure( pt->isValid() );
ensure( pt->getCoordinate() != 0 );
CoordinateCPtr pcoord = pt->getCoordinate();
ensure( pcoord != 0 );
ensure_equals( pcoord->x, x_ );
ensure_equals( pcoord->y, y_ );
ensure_equals( pcoord->z, z_ );
GeometryPtr geo = 0;
geo = pt->getEnvelope();
ensure( geo != 0 );
ensure( !geo->isEmpty() );
factory_.destroyGeometry(geo);
geo = pt->getCentroid();
ensure( geo != 0 );
ensure( !geo->isEmpty() );
factory_.destroyGeometry(geo);
geo = pt->getBoundary();
ensure( geo != 0 );
ensure( geo->isEmpty() );
factory_.destroyGeometry(geo);
geo = pt->convexHull();
ensure( geo != 0 );
ensure( !geo->isEmpty() );
factory_.destroyGeometry(geo);
ensure_equals( pt->getGeometryTypeId(), geos::geom::GEOS_POINT );
ensure_equals( pt->getDimension(), geos::geom::Dimension::P );
ensure_equals( pt->getBoundaryDimension(), geos::geom::Dimension::False );
ensure_equals( pt->getNumPoints(), 1u );
ensure_equals( pt->getLength(), 0.0 );
ensure_equals( pt->getArea(), 0.0 );
// FREE MEMORY
factory_.destroyGeometry(pt);
}
示例3: type
void object::test<25>()
{
GeometryPtr geo = reader_.read("LINESTRING (0 0, 10 10, 20 0)");
ensure( geo != 0 );
const std::string type("LineString");
ensure_equals( geo->getGeometryType(), type );
// FREE MEMORY
factory_.destroyGeometry(geo);
}
示例4: ensure
void object::test<4>()
{
using geos::geom::Coordinate;
// Non-empty sequence of coordiantes
const size_t size = 3;
CoordArrayPtr pseq = new geos::geom::CoordinateArraySequence();
ensure( "sequence is null pointer.", pseq != 0 );
pseq->add(Coordinate(0, 0, 0));
pseq->add(Coordinate(5, 5, 5));
pseq->add(Coordinate(10, 10, 10));
ensure_equals( pseq->size(), size );
// Create examplar of linstring instance
LineStringAutoPtr examplar(factory_.createLineString(pseq));
// Create copy
LineStringAutoPtr copy(dynamic_cast<geos::geom::LineString*>(examplar->clone()));
ensure( 0 != copy.get() );
ensure( !copy->isEmpty() );
ensure( copy->isSimple() );
ensure( copy->isValid() );
ensure( !copy->isClosed() );
ensure( !copy->isRing() );
GeometryPtr geo = 0;
geo = copy->getEnvelope();
ensure( geo != 0 );
ensure( !geo->isEmpty() );
factory_.destroyGeometry(geo);
geo = copy->getBoundary();
ensure( geo != 0 );
ensure( !geo->isEmpty() );
factory_.destroyGeometry(geo);
geo = copy->convexHull();
ensure( geo != 0 );
ensure( !geo->isEmpty() );
factory_.destroyGeometry(geo);
ensure_equals( copy->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
ensure_equals( copy->getDimension(), geos::geom::Dimension::L );
ensure_equals( copy->getBoundaryDimension(), geos::geom::Dimension::P );
ensure_equals( copy->getNumPoints(), size );
ensure_equals( copy->getArea(), 0.0 );
ensure( copy->getLength() != 0.0 );
}
示例5:
void object::test<22>()
{
const size_t size = 4;
GeometryPtr geo = reader_.read("LINESTRING (0 0, 5 5, 10 5, 10 10)");
ensure( geo != 0 );
ensure_equals( geo->getNumPoints(), size );
// FREE TESTED LINESTRING
factory_.destroyGeometry(geo);
}
示例6: ensure
void object::test<17>()
{
ensure( poly_ != nullptr );
GeometryPtr envelope = poly_->getEnvelope();
ensure( envelope != nullptr );
ensure( !envelope->isEmpty() );
ensure_equals( envelope->getDimension(), geos::geom::Dimension::A );
// FREE MEMORY
factory_->destroyGeometry(envelope);
}
示例7: renderGeometry
void GlUtils::renderGeometry(
const GeometryPtr & geometry,
gl::ProgramPtr program) {
program->use();
Stacks::lights().apply(program);
Stacks::projection().apply(program);
Stacks::modelview().apply(program);
geometry->bindVertexArray();
geometry->draw();
VertexArray::unbind();
Program::clear();
}
示例8: getProgram
void GlUtils::draw3dVector(glm::vec3 vec, const glm::vec3 & col) {
Mesh m;
m.color = Colors::gray;
m.addVertex(glm::vec3());
m.addVertex(glm::vec3(vec.x, 0, vec.z));
m.addVertex(glm::vec3(vec.x, 0, vec.z));
m.addVertex(vec);
m.fillColors(true);
m.color = col;
m.addVertex(vec);
m.addVertex(glm::vec3());
m.fillColors();
static GeometryPtr g = m.getGeometry(GL_LINES);
g->updateVertices(m.buildVertices());
ProgramPtr program = getProgram(
Resource::SHADERS_COLORED_VS,
Resource::SHADERS_COLORED_FS);
program->use();
renderGeometry(g, program);
gl::Program::clear();
// lineWidth(1.0f);
// float len = glm::length(vec);
// if (len > 1.0f) {
// vec /= len;
// }
// gl::Program::clear();
//
// glLineWidth(2.0f + len);
// glBegin(GL_LINES);
// gl::color(col);
// gl::vertex();
// gl::vertex();
// glEnd();
//
// glLineWidth(1.0f);
// glBegin(GL_LINE_STRIP);
// gl::color(Colors::gray);
// gl::vertex(glm::vec3());
// gl::vertex(glm::vec3(vec.x, 0, vec.z));
// gl::vertex(vec);
// glEnd();
}
示例9: kml2tessellate_rec
int kml2tessellate_rec (
GeometryPtr poKmlGeometry,
int *pnTessellate )
{
LineStringPtr poKmlLineString;
PolygonPtr poKmlPolygon;
MultiGeometryPtr poKmlMultiGeometry;
size_t nGeom;
size_t i;
switch ( poKmlGeometry->Type ( ) ) {
case kmldom::Type_Point:
break;
case kmldom::Type_LineString:
poKmlLineString = AsLineString ( poKmlGeometry );
if ( poKmlLineString->has_tessellate ( ) ) {
*pnTessellate = poKmlLineString->get_tessellate ( );
return TRUE;
}
break;
case kmldom::Type_LinearRing:
break;
case kmldom::Type_Polygon:
poKmlPolygon = AsPolygon ( poKmlGeometry );
if ( poKmlPolygon->has_tessellate ( ) ) {
*pnTessellate = poKmlPolygon->get_tessellate ( );
return TRUE;
}
break;
case kmldom::Type_MultiGeometry:
poKmlMultiGeometry = AsMultiGeometry ( poKmlGeometry );
nGeom = poKmlMultiGeometry->get_geometry_array_size ( );
for ( i = 0; i < nGeom; i++ ) {
if ( kml2tessellate_rec ( poKmlMultiGeometry->
get_geometry_array_at ( i ),
pnTessellate ) )
return TRUE;
}
break;
default:
break;
}
return FALSE;
}
示例10: pm
void object::test<5>()
{
using geos::geom::PrecisionModel;
PrecisionModel pm(PrecisionModel::FIXED);
geos::geom::GeometryFactory gf(&pm, srid_);
ensure_equals( gf.getSRID(), srid_ );
ensure_equals( gf.getPrecisionModel()->getType(), PrecisionModel::FIXED );
GeometryPtr geo = gf.createEmptyGeometry();
ensure( "createEmptyGeometry() returned null pointer.", geo != 0 );
ensure_equals( geo->getSRID() , gf.getSRID() );
ensure_equals( geo->getPrecisionModel()->getType(), PrecisionModel::FIXED );
// FREE MEMORY
gf.destroyGeometry(geo);
}
示例11: beginEditCP
typename Spatialize<BasicTraits>::ResultT
Spatialize<BasicTraits>::LeafEnter (AdapterType* node)
{
// create new node with transformed positions and normals
NodePtr newNode = Node::create();
GeometryPtr oldCore = GeometryPtr::dcast(node->getOriginal()->getCore());
GeometryPtr newCore = oldCore->clone();
beginEditCP(newNode);
newNode->setCore(newCore);
endEditCP(newNode);
beginEditCP(newCore);
newCore->setPositions(node->getPositions());
newCore->setNormals (node->getNormals());
endEditCP(newCore);
m_rootLevel->addChild(newNode);
return SingleTraverserBase<BasicTraits>::CONTINUE;
}
示例12: createGeo
GeometryPtr createGeo(UInt32 mat)
{
GeoIndicesPtr ind = _ind[mat];
FDEBUG(("CreateGeoRec::createGeo: Mat %d: %d inds (%d tris)\n",
mat, ind->getSize(), ind->getSize()/3));
endEditCP(ind);
GeometryPtr geo = Geometry::create();
GeoPLengthsUI32Ptr len = GeoPLengthsUI32::create();
beginEditCP(len);
len->push_back(ind->getSize());
endEditCP(len);
GeoPTypesUI8Ptr typ = GeoPTypesUI8::create();
beginEditCP(typ);
typ->push_back(GL_TRIANGLES);
endEditCP(typ);
beginEditCP(geo);
if(random_color)
{
SimpleMaterialPtr mat = SimpleMaterial::create();
beginEditCP(mat);
Color3f c( drand48() * .7f + .3f,
drand48() * .7f + .3f,
drand48() * .7f + .3f);
mat->setDiffuse(c);
mat->setSpecular(Color3f(1.f,1.f,1.f));
mat->setShininess(10.f);
endEditCP(mat);
geo->setMaterial(mat);
}
else
{
geo->setMaterial(MaterialPool::getMaterial(mat));
}
geo->setPositions(_pos);
geo->setIndices(ind);
geo->setLengths(len);
geo->setTypes(typ);
geo->getIndexMapping().push_back(Geometry::MapPosition);
endEditCP(geo);
calcVertexNormals(geo);
//calcFaceNormals(geo);
createSingleIndex(geo);
return geo;
}
示例13: ensure
void object::test<18>()
{
PolygonPtr poly = factory_.createPolygon();
ensure( "createPolygon() returned null pointer.", poly != 0 );
ensure( "createPolygon() returned non-empty point.", poly->isEmpty() );
ensure( poly->isSimple() );
ensure( poly->isValid() );
ensure( poly->getCentroid() == 0 );
// TODO - mloskot - waiting for some decision
// http://geos.refractions.net/pipermail/geos-devel/2006-March/002006.html
//ensure( poly->getCoordinate() == 0 );
GeometryPtr geo = 0;
// TODO - mloskot - waiting for resolution
// http://geos.refractions.net/pipermail/geos-devel/2006-March/002011.html
//geo = poly->getEnvelope();
//ensure( geo != 0 );
//ensure( geo->isEmpty() );
//factory_.destroyGeometry(geo);
geo = poly->getBoundary();
ensure( geo != 0 );
ensure( geo->isEmpty() );
factory_.destroyGeometry(geo);
geo = poly->convexHull();
ensure( geo != 0 );
ensure( geo->isEmpty() );
factory_.destroyGeometry(geo);
ensure_equals( poly->getGeometryTypeId(), geos::geom::GEOS_POLYGON );
ensure_equals( poly->getDimension(), geos::geom::Dimension::A );
ensure_equals( poly->getBoundaryDimension(), geos::geom::Dimension::L );
ensure_equals( poly->getNumPoints(), 0u );
ensure_equals( poly->getLength(), 0.0 );
ensure_equals( poly->getArea(), 0.0 );
// FREE MEMORY
factory_.destroyGeometry(poly);
}
示例14: GeometryPtr
void SDFShadowDemo::BuildQuad()
{
// create a screen quad
m_pQuad = GeometryPtr(new GeometryDX11());
const i32 NumVertexOfQuad = 4;
// create the vertex element streams
VertexElementDX11* pPositions = new VertexElementDX11(3, NumVertexOfQuad);
pPositions->m_SemanticName = VertexElementDX11::PositionSemantic;
pPositions->m_uiSemanticIndex = 0;
pPositions->m_Format = DXGI_FORMAT_R32G32B32_FLOAT;
pPositions->m_uiInputSlot = 0;
pPositions->m_uiAlignedByteOffset = 0;
pPositions->m_InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
pPositions->m_uiInstanceDataStepRate = 0;
VertexElementDX11* pColors = new VertexElementDX11(4, NumVertexOfQuad);
pColors->m_SemanticName = VertexElementDX11::ColorSemantic;
pColors->m_uiSemanticIndex = 0;
pColors->m_Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
pColors->m_uiInputSlot = 0;
pColors->m_uiAlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
pColors->m_InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
pColors->m_uiInstanceDataStepRate = 0;
m_pQuad->AddElement(pPositions);
m_pQuad->AddElement(pColors);
*pPositions->Get3f(0) = Vector3f(-1.0f, +1.0f, 0.0f);
*pPositions->Get3f(1) = Vector3f(+1.0f, +1.0f, 0.0f);
*pPositions->Get3f(2) = Vector3f(-1.0f, -1.0f, 0.0f);
*pPositions->Get3f(3) = Vector3f(+1.0f, -1.0f, 0.0f);
*pColors->Get4f(0) = Colors::White;
*pColors->Get4f(1) = Colors::White;
*pColors->Get4f(2) = Colors::White;
*pColors->Get4f(3) = Colors::White;
m_pQuad->AddFace(TriangleIndices(0, 1, 2));
m_pQuad->AddFace(TriangleIndices(1, 3, 2));
m_pQuad->LoadToBuffers();
}
示例15:
void object::test<7>()
{
GeometryPtr geo = factory_.createEmptyGeometry();
ensure( "createEmptyGeometry() returned null pointer.", geo != 0 );
ensure( "createEmptyGeometry() returned non-empty geometry.", geo->isEmpty() );
// TODO - mloskot
// http://geos.refractions.net/pipermail/geos-devel/2006-March/001960.html
/*
ensure( geo->isSimple() );
ensure( geo->isValid() );
ensure( geo->getCentroid() == 0 );
ensure( geo->getCoordinate() == 0 );
*/
// FREE MEMORY
factory_.destroyGeometry(geo);
}