本文整理汇总了C++中FaceSet类的典型用法代码示例。如果您正苦于以下问题:C++ FaceSet类的具体用法?C++ FaceSet怎么用?C++ FaceSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FaceSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetFromFaces
void Box::SetFromFaces(FaceSet& faces) {
if (faces.Size() == 0) return;
// initialize max and min with the first member of the face set
FaceList::iterator itr = faces.begin();
Vector<3,float> max((*itr)->vert[0]);
Vector<3,float> min(max);
// find the boundary values
for (; itr != faces.end(); itr++) {
for (int i=0; i<3; i++) {
Vector<3,float> v = (*itr)->vert[i];
for (int j=0; j<3; j++)
if (v[j] < min[j]) min[j] = v[j];
else if (v[j] > max[j]) max[j] = v[j];
}
}
// set box center
center = (max - min) / 2 + min;
// set corner vector
corner = max - center;
// compute the corners
float x = corner[0];
float y = corner[1];
float z = corner[2];
SetCorner(1,1,1, center+Vector<3,float>( x, y, z));
SetCorner(1,1,0, center+Vector<3,float>( x, y,-z));
SetCorner(1,0,1, center+Vector<3,float>( x,-y, z));
SetCorner(1,0,0, center+Vector<3,float>( x,-y,-z));
SetCorner(0,1,1, center+Vector<3,float>(-x, y, z));
SetCorner(0,1,0, center+Vector<3,float>(-x, y,-z));
SetCorner(0,0,1, center+Vector<3,float>(-x,-y, z));
SetCorner(0,0,0, center+Vector<3,float>(-x,-y,-z));
}
示例2: BrushGeometry
void Brush::rebuildGeometry() {
delete m_geometry;
m_geometry = new BrushGeometry(m_worldBounds);
// sort the faces by the weight of their plane normals like QBSP does
Model::FaceList sortedFaces = m_faces;
std::sort(sortedFaces.begin(), sortedFaces.end(), Model::Face::WeightOrder(Planef::WeightOrder(true)));
std::sort(sortedFaces.begin(), sortedFaces.end(), Model::Face::WeightOrder(Planef::WeightOrder(false)));
FaceSet droppedFaces;
bool success = m_geometry->addFaces(sortedFaces, droppedFaces);
assert(success);
for (FaceSet::iterator it = droppedFaces.begin(); it != droppedFaces.end(); ++it) {
Face* face = *it;
face->setBrush(NULL);
m_faces.erase(std::remove(m_faces.begin(), m_faces.end(), face), m_faces.end());
delete face;
}
for (FaceList::iterator it = m_faces.begin(); it != m_faces.end(); ++it) {
Face* face = *it;
face->invalidateTexAxes();
face->invalidateVertexCache();
}
if (m_entity != NULL)
m_entity->invalidateGeometry();
}
示例3: VisitGeometryNode
/**
* The Geometry nodes textures are loaded on visit
*
* @param node Geometry node
*/
void TextureLoader::VisitGeometryNode(GeometryNode* node) {
FaceSet* faces = node->GetFaceSet();
if (faces == NULL) return;
for (FaceList::iterator face = faces->begin(); face != faces->end(); face++) {
// load face textures
LoadTextureResource((*face)->texr);
}
}
示例4: GetFaces
void Geometry::Shape2Polygons(const TopoDS_Shape &s, Geometry::PolySet &polys) {
FaceSet faces;
GetFaces(s,faces);
pcl::PlanarPolygon<PointT> poly;
for (FaceSet::iterator it = faces.begin();it!=faces.end();++it) {
polys.push_back(new pcl::PlanarPolygon<PointT>);
Face2Polygon(*it,poly);
polys.at(polys.size()-1)=poly;
}
}
示例5: BRepMesh_IncrementalMesh
void Geometry::Shape2BVHMesh(const TopoDS_Shape &shape, BVHMeshPtr model) {
model->beginModel();
BRepMesh_IncrementalMesh(shape, IfcGeom::GetValue(IfcGeom::GV_DEFLECTION_TOLERANCE));
FaceSet faces;
GetFaces(shape,faces);
for (auto face=faces.begin();face!=faces.end();++face){
Face2BVHMesh(*face,model);
}
model->endModel();
}
示例6: getBoundaryFaces
/*! \brief fetch all faces on the boundary of the model */
FaceSet TopologySet::getBoundaryFaces() {
FaceSet results;
FaceSet::iterator it;
if(volumetric_model) {
for(it=face_.begin(); it != face_.end(); it++)
if((*it)->volume.size() == 1) // faces neighbouring only one volume are on edges
if(! (*it)->isDegen()) // skip completely degenerate faces
if((*it)->volume[0]->getSurfaceEnumeration(*it).size() == 1) // periodic patch faces are not part of boundary
results.insert(*it);
} else if(surface_model) {
results = face_;
}
return results; // empty set
}
示例7: SetupLight
void SetupLight(Config& config) {
// Set up a light node
PointLightNode* pln = config.setup.GetShadowLightNode();
pln->active = true;
//draw something at the pos of the light node
FacePtr face1(new Face(Vector<3, float>(0,0,0), Vector<3, float>(-10,0,10),
Vector<3, float>(-10,0,-10), Vector<3, float>(0,1,0),
Vector<3, float>(0,1,0), Vector<3, float>(0,1,0)));
FacePtr face2(new Face(Vector<3, float>(0,0,0), Vector<3, float>(10,0,-10),
Vector<3, float>(10,0,10), Vector<3, float>(0,1,0),
Vector<3, float>(0,1,0), Vector<3, float>(0,1,0)));
Vector<4,float> color = Vector<4,float>(1.0,0.0,0.0,0.0);
face1->colr[0] = color;
face1->colr[1] = color;
face1->colr[2] = color;
face2->colr[0] = color;
face2->colr[1] = color;
face2->colr[2] = color;
FaceSet* faceSet = new FaceSet();
faceSet->Add(face1);
faceSet->Add(face2);
GeometryNode* geom = new GeometryNode(faceSet);
TransformationNode* light_geom_lift = new TransformationNode();
light_geom_lift->SetPosition(Vector<3, float>(0, 10, 0));
light_geom_lift->AddNode(geom);
pln->AddNode(light_geom_lift);
// Attach light node
TransformationNode* light_tran = new TransformationNode();
light_tran->SetPosition(Vector<3, float>(0, 100, 200));
light_tran->AddNode(pln);
config.lightTrans = light_tran;
LightRenderer* lr = new LightRenderer(*config.camera);
config.setup.GetRenderer().InitializeEvent().Attach(*lr);
config.setup.GetRenderer().PreProcessEvent().Attach(*lr);
config.setup.GetRenderer().DeinitializeEvent().Attach(*lr);
RenderStateNode* rsn = new RenderStateNode();
rsn->EnableOption(RenderStateNode::LIGHTING);
config.renderingScene = rsn;
}
示例8: sin
FaceSet* SkyDome::CreateDome(int horiRes, int vertRes, float texturePercentage, float domePercentage, float radius, Vector<3,float> center, ITextureResourcePtr texture) {
// COPYRIGHT NOTICE: Code in this method is based on code written by Anders la Cour-Harbo for the irrlicht engine
if (domePercentage < 0.0) domePercentage =- domePercentage;
if (domePercentage > 2.0) domePercentage = 2.0;
float azimuth = 0.0;
float azimuth_step = 2.0 * Math::PI / (float)horiRes;
float elevation_step = domePercentage * Math::PI / 2.0 / (float)vertRes;
const float tcV = (float)texturePercentage / (float)vertRes;
for (int i = 0; i <= horiRes; i++) {
float elevation = Math::PI / 2.0;
const float tcU = (float)i / (float)horiRes;
const float sinA = sin(azimuth);
const float cosA = cos(azimuth);
for (int j = 0; j <= vertRes; j++) {
const float cosEr = radius * cos(elevation);
Vector<3,float> pos((cosEr * sinA),
(radius * sin(elevation) + 50.0f),
(cosEr * cosA));
positions.push_back(pos);
texCoords.push_back(Vector<2,float>(tcU, (float)j*tcV));
elevation -= elevation_step;
}
azimuth += azimuth_step;
}
FaceSet* faces = new FaceSet();
for (int i = 0; i < horiRes; i++) {
faces->Add(CreateDomeFace(vertRes+2+(vertRes+1)*i, 1+(vertRes+1)*i, 0+(vertRes+1)*i, texture));
for (int j = 1; j < vertRes; j++) {
faces->Add(CreateDomeFace(vertRes+2+(vertRes+1)*i+j, 1+(vertRes+1)*i+j, 0+(vertRes+1)*i+j, texture));
faces->Add(CreateDomeFace(vertRes+1+(vertRes+1)*i+j, vertRes+2+(vertRes+1)*i+j, 0+(vertRes+1)*i+j, texture));
}
}
positions.clear();
texCoords.clear();
return faces;
}
示例9: moveFaces
FaceInfoList Brush::moveFaces(const FaceInfoList& faceInfos, const Vec3f& delta) {
FaceSet newFaces;
FaceSet droppedFaces;
const FaceInfoList newFaceInfos = m_geometry->moveFaces(m_worldBounds, faceInfos, delta, newFaces, droppedFaces);
for (FaceSet::iterator it = droppedFaces.begin(); it != droppedFaces.end(); ++it) {
Face* face = *it;
face->setBrush(NULL);
m_faces.erase(std::remove(m_faces.begin(), m_faces.end(), face), m_faces.end());
delete face;
}
for (FaceList::iterator it = m_faces.begin(); it != m_faces.end(); ++it) {
Face* face = *it;
face->invalidateTexAxes();
face->invalidateVertexCache();
}
for (FaceSet::iterator it = newFaces.begin(); it != newFaces.end(); ++it) {
Face* face = *it;
face->setBrush(this);
m_faces.push_back(face);
}
setNeedsRebuild(true);
return newFaceInfos;
}
示例10: splitFace
Vec3f Brush::splitFace(const FaceInfo& faceInfo, const Vec3f& delta) {
FaceSet newFaces;
FaceSet droppedFaces;
Vec3f newVertexPosition = m_geometry->splitFace(m_worldBounds, faceInfo, delta, newFaces, droppedFaces);
for (FaceSet::iterator it = droppedFaces.begin(); it != droppedFaces.end(); ++it) {
Face* dropFace = *it;
dropFace->setBrush(NULL);
m_faces.erase(std::remove(m_faces.begin(), m_faces.end(), dropFace), m_faces.end());
delete dropFace;
}
for (FaceList::iterator it = m_faces.begin(); it != m_faces.end(); ++it) {
Face* face = *it;
face->invalidateTexAxes();
face->invalidateVertexCache();
}
for (FaceSet::iterator it = newFaces.begin(); it != newFaces.end(); ++it) {
Face* newFace = *it;
newFace->setBrush(this);
m_faces.push_back(newFace);
}
setNeedsRebuild(true);
return newVertexPosition;
}
示例11: translationMatrix
bool Brush::canMoveBoundary(const Face& face, const Vec3f& delta) const {
const Mat4f pointTransform = translationMatrix(delta);
BrushGeometry testGeometry(m_worldBounds);
Face testFace(face);
testFace.transform(pointTransform, Mat4f::Identity, false, false);
FaceSet droppedFaces;
FaceList::const_iterator it, end;
for (it = m_faces.begin(), end = m_faces.end(); it != end; ++it) {
Face* otherFace = *it;
if (otherFace != &face)
testGeometry.addFace(*otherFace, droppedFaces);
}
BrushGeometry::CutResult result = testGeometry.addFace(testFace, droppedFaces);
bool inWorldBounds = m_worldBounds.contains(testGeometry.bounds);
m_geometry->restoreFaceSides();
return inWorldBounds && result == BrushGeometry::Split && droppedFaces.empty();
}
示例12: snap
void Brush::snap(unsigned int snapTo) {
FaceSet newFaces;
FaceSet droppedFaces;
m_geometry->snap(newFaces, droppedFaces, snapTo);
for (FaceSet::iterator it = droppedFaces.begin(); it != droppedFaces.end(); ++it) {
Face* face = *it;
face->setBrush(NULL);
m_faces.erase(std::remove(m_faces.begin(), m_faces.end(), face), m_faces.end());
delete face;
}
for (FaceSet::iterator it = newFaces.begin(); it != newFaces.end(); ++it) {
Face* face = *it;
face->setBrush(this);
m_faces.push_back(face);
}
rebuildGeometry();
}
示例13: correct
void Brush::correct(float epsilon) {
FaceSet newFaces;
FaceSet droppedFaces;
m_geometry->correct(newFaces, droppedFaces, epsilon);
for (FaceSet::iterator it = droppedFaces.begin(); it != droppedFaces.end(); ++it) {
Face* face = *it;
face->setBrush(NULL);
m_faces.erase(std::remove(m_faces.begin(), m_faces.end(), face), m_faces.end());
delete face;
}
for (FaceSet::iterator it = newFaces.begin(); it != newFaces.end(); ++it) {
Face* face = *it;
face->setBrush(this);
m_faces.push_back(face);
}
rebuildGeometry();
}
示例14: memset
void PointSet::CreateDelaunayOnSphere(PointSet* ps, FaceSet* fs, double* progress, std::stringstream* myMsg)
{
double dummy = 0;
if ( progress==NULL ) progress = &dummy;
int p_num = ps->GetCount();
PointSet tmpPS;
tmpPS.count = p_num;
tmpPS.capacity = p_num*2+4;
tmpPS.points = new Point4D [tmpPS.capacity];
const double OVERWRAP = 0.1;
int* OverwrapID = new int [p_num*2];
memset( OverwrapID, -1, sizeof(int)*2*p_num );
double center[3];
// Estimate Center
{
double pntRange[] = {
DBL_MAX, DBL_MAX, DBL_MAX,
-DBL_MAX, -DBL_MAX, -DBL_MAX,
};
for ( int i=0 ; i < p_num; i++ ) {
Point4D pnt = ps->GetPoint4DAt(i);
for ( int j=0; j < 3; j++ ) {
pntRange[j+0] = ( pntRange[j+0]>pnt.GetPoint(j) ? pnt.GetPoint(j) : pntRange[j+0]);
pntRange[j+3] = ( pntRange[j+3]<pnt.GetPoint(j) ? pnt.GetPoint(j) : pntRange[j+3]);
}
}
for ( int j=0; j < 3; j++ ) {
center[j] = ( pntRange[j+3]+pntRange[j+0] )/2;
}
}
// Project onto Sphere
{
Point4D Center( center[0], center[1], center[2] );
for ( int i=0; i < p_num; i++ ) {
double CntPnt[3];
(ps->GetPoint4DAt(i)-Center).GetPoint(CntPnt);
double lng = atan(CntPnt[1]/CntPnt[2])+( CntPnt[2]>0 ? 0 : M_PI ) +M_PI/2;
double lat = atan( CntPnt[0]/sqrt(CntPnt[1]*CntPnt[1]+CntPnt[2]*CntPnt[2]) ) +M_PI/2;
OverwrapID[i] = i;
tmpPS.points[i].SetPoint( lng, lat, lng*lng+lat*lat);
if ( lng < OVERWRAP ) {
OverwrapID[tmpPS.count] = i;
tmpPS.points[tmpPS.count++].SetPoint( lng+2*M_PI, lat, (lng+2*M_PI)*(lng+2*M_PI)+lat*lat );
}
}
}
// 外接4角形の作成
tmpPS.count += 4;
tmpPS.points[tmpPS.count-4].SetPoint( 6*M_PI, 2*M_PI, M_PI*M_PI*40 );
tmpPS.points[tmpPS.count-3].SetPoint( 6*M_PI, -1*M_PI, M_PI*M_PI*37 );
tmpPS.points[tmpPS.count-2].SetPoint( -2*M_PI, -1*M_PI, M_PI*M_PI*5 );
tmpPS.points[tmpPS.count-1].SetPoint( -2*M_PI, 2*M_PI, M_PI*M_PI*8 );
FaceSet myFS;
myFS.AddNewFace( tmpPS.count-2, tmpPS.count-3, tmpPS.count-4 );
myFS.AddNewFace( tmpPS.count-4, tmpPS.count-1, tmpPS.count-2 );
if ( !myFS.CheckDelaunay( &tmpPS ) ) {
// AfxMessageBox("Invalid initial Delaunay.", MB_ICONERROR);
// return;
throw "Invalid initial Delaunay.";
}
myFS.MakeDelaunay( &tmpPS, progress, myMsg );
for ( int i=1; i <= 4; i++ ) {
myFS.RemoveFaceV(tmpPS.count-i);
}
// IDの整理
{
int f_num = myFS.GetFaceCount(), *f_list=NULL ;
myFS.GetFaceIDList( &f_list, true );
for ( int i=0; i < f_num; i++ ) {
myFS.RemoveFace(i);
ASSERT(OverwrapID[f_list[i*3+0]]!=-1);
ASSERT(OverwrapID[f_list[i*3+1]]!=-1);
ASSERT(OverwrapID[f_list[i*3+2]]!=-1);
myFS.AddNewFace( OverwrapID[f_list[i*3+0]], OverwrapID[f_list[i*3+1]], OverwrapID[f_list[i*3+2]] );
}
delete [] f_list;
}
myFS.Unduplication();
delete [] OverwrapID;
*fs = myFS;
}
示例15: cvInitMatHeader
void PointSet::CreateDelaunay(PointSet* ps, double* projMat, FaceSet* fs, double* progress, std::stringstream* myMsg)
{
double dummy = 0;
if ( progress==NULL ) progress = &dummy;
double max[]={ -DBL_MAX, -DBL_MAX, }, min[]={ DBL_MAX, DBL_MAX, }, cent[2], radius;
PointSet tmpPS;
tmpPS.count = ps->GetCount()+4;
tmpPS.points = new Point4D [tmpPS.count];
CvMat M_Prj, M_Src, M_Trg;
cvInitMatHeader( &M_Prj, 4, 4, CV_64FC1, projMat );
for ( int i=0; i < tmpPS.count-4; i++ ) {
double p[2][4];
ps->GetPoint4DAt(i).GetPoint(p[0]);
p[0][3] = 1;
cvInitMatHeader( &M_Src, 4, 1, CV_64FC1, p[0] );
cvInitMatHeader( &M_Trg, 4, 1, CV_64FC1, p[1] );
cvMatMul( &M_Prj, &M_Src, &M_Trg );
p[1][2] = (p[1][0]*p[1][0]+p[1][1]*p[1][1]);
p[1][3] = 1;
if ( p[1][0] < min[0] ) min[0]=p[1][0];
if ( p[1][0] > max[0] ) max[0]=p[1][0];
if ( p[1][1] < min[1] ) min[1]=p[1][1];
if ( p[1][1] > max[1] ) max[1]=p[1][1];
tmpPS.points[i].SetPoint(p[1]);
}
min[0] -= 1;
min[1] -= 1;
max[0] += 1;
max[1] += 1;
cent[0] = ( max[0]+min[0] )/2;
cent[1] = ( max[1]+min[1] )/2;
radius = sqrt( (max[0]-min[0])*(max[0]-min[0]) + (max[1]-min[1])*(max[1]-min[1]) );
// 外接4角形の作成
for ( int i=1; i <= 4; i++ ) {
double coord[2] = {
cent[0]+radius*cos(M_PI/2*i)*1.01,
cent[1]+radius*sin(M_PI/2*i),
};
tmpPS.points[tmpPS.count-i].SetPoint( coord[0], coord[1], coord[0]*coord[0]+coord[1]*coord[1] );
}
FaceSet myFS;
myFS.AddNewFace( tmpPS.count-2, tmpPS.count-3, tmpPS.count-4 );
myFS.AddNewFace( tmpPS.count-4, tmpPS.count-1, tmpPS.count-2 );
if ( !myFS.CheckDelaunay( &tmpPS ) ) {
//AfxMessageBox("Invalid initial Delaunay.", MB_ICONERROR);
//return;
throw "Invalid initial Delaunay.";
}
myFS.MakeDelaunay( &tmpPS, progress, myMsg );
for ( int i=1; i <= 4; i++ ) {
myFS.RemoveFaceV(tmpPS.count-i);
}
*fs = myFS;
}