static void SetEdgeLineVisibility (Facet& f, 
                                   int a, int AzmStride,
                                   int p, int PolStride, 
                                   bool ReverseOrientation = false)
{
  // no individual setting, visibility is either true or false
  if (AzmStride == 1 && PolStride == 1) return;

  // individual setting
  int mask = 0;

  // three or four vertices
  if (ReverseOrientation) {
    if ((a+1) % AzmStride == 0) mask |= 4;
    if ( a    % AzmStride == 0) mask |= 1;
  } else {
    if ((a+1) % AzmStride == 0) mask |= 1;
    if ( a    % AzmStride == 0) mask |= 4;
  }
  
  if (p % PolStride == 0) mask |= 2;

  // four vertices
  if (f.GetNumVertices() == 4) 
    if ((p+1) % PolStride == 0) mask |= 8;

  // set edge line visibility
  f.SetEdgeLineVisibility(Facet::Individual,mask);
}
// Place un point p sur la face fs, et relie p aux sommets de fs.
Halfedge_handle DegradeAnObject::putAPointOnAFacet(Point_3 p, int index) {
	Facet fs;
	getFacetFromPoint(p, fs, index);
	Halfedge_handle h = polys[index].create_center_vertex(fs.halfedge());
	h->vertex()->point() = p;
	return h;
}
Beispiel #3
0
bool STLWriter::writeSTLFacet(const Facet& facet, const bool& isBinaryMode)
{
    if(isBinaryMode)
    {
        char* c = new char[12 * sizeof(float) + 2];

        ((float*) c)[0] = facet.getNormal()[0];
        ((float*) c)[1] = facet.getNormal()[1];
        ((float*) c)[2] = facet.getNormal()[2];

        for(int i = 0; i < NUM_VERTICES; ++i)
        {
            ((float*) c)[i + 0 + 2] = facet.getVertexAt(i).x;
            ((float*) c)[i + 1 + 2] = facet.getVertexAt(i).y;
            ((float*) c)[i + 2 + 2] = facet.getVertexAt(i).z;
        }

        outputFile_.write(c, 12 * sizeof(float) + 2);
    }
    else
    {
        string s = buildFacetString(facet);
        outputFile_.write(s.data(), s.length());
    }

    return true;
}
Beispiel #4
0
string STLWriter::buildFacetString(const Facet& facet)
{
    normal n = facet.getNormal();
    vertices v = facet.getVertices();
    std::ostringstream ss;
    string ret = "\nfacet normal ";

    for(size_t i = 0; i < n.size(); ++i)
    {
        ss << n[i];
        ret += ss.str() + " ";
    }

    ret += "\n\t outer loop\n";

    for(size_t i = 0; i < v.size(); ++i)
    {
        ret += "\t\tvertex ";
        
        ss << v[i].x;
        ret += ss.str() + " ";

        ss << v[i].y;
        ret += ss.str() + " ";

        ss << v[i].z;
        ret += ss.str() + " ";
        
        ret += "\n";
    }

    ret += "\tendloop\n";
    ret += "endfacet\n";
    return ret;
}
Beispiel #5
0
char Facet::isClosed() const
{
	for (int i=0; i<3; i++) 
	{
         Edge *opposite = m_edges[i]->getTwin();
		 if(!opposite) 
		 {
			printf("edge not connected\n");
			return 0;
		}
		 Facet * f = (Facet *)(opposite->getFace());
		 
		 if(!f){
			printf("edge has no face\n");
			return 0;
		}
		
		if(f->getIndex() < 0)
		{
			printf("face %d is removed\n", f->getIndex());
			return 0;
		}
		 
	}
	
	return 1;
}
Beispiel #6
0
void ComponentConversion::vertexToPolygon(const std::vector<unsigned> & src, std::vector<unsigned> & polyIds, std::vector<unsigned> & vppIds) const
{
	if(src.size() < 2) return;
	
	std::vector<unsigned>::const_iterator it0;
	std::vector<unsigned>::const_iterator it1 = src.begin();
	it1++;
	for(; it1 != src.end(); ++it1) {
		it0 = it1;
		it0--;
		
		VertexAdjacency & adj = m_topology->getAdjacency(*it0);
		char found = 0;
		Edge * e = adj.connectedToVertexBy(*it1, found);
		if(found) {
			Facet *f = (Facet *)e->getFace();
			if(appendUnique(f->getPolygonIndex(), polyIds)) {
				vppIds.push_back(*it0);
				vppIds.push_back(*it1);
			}
			
			Edge *opp = e->getTwin();
			if(opp) {
				f = (Facet *)opp->getFace();
				if(appendUnique(f->getPolygonIndex(), polyIds)) {
					vppIds.push_back(*it0);
					vppIds.push_back(*it1);
				}
			}
		}
	}
}
Beispiel #7
0
//-----------------------------------------------------------------------------
double HexahedronCell::facet_area(const Cell& cell, std::size_t facet) const
{
  // Create facet from the mesh and local facet number
  const Facet f(cell.mesh(), cell.entities(1)[facet]);

  // Get global index of vertices on the facet
  const std::size_t v0 = f.entities(0)[0];
  const std::size_t v1 = f.entities(0)[1];
  const std::size_t v2 = f.entities(0)[2];
  const std::size_t v3 = f.entities(0)[3];

  // Get mesh geometry
  const MeshGeometry& geometry = cell.mesh().geometry();

  // Need to check points are co-planar

  const Point p0 = geometry.point(v0);
  const Point p1 = geometry.point(v1);
  const Point p2 = geometry.point(v2);
  const Point p3 = geometry.point(v3);

  dolfin_not_implemented();

  return 0.0;
}
Beispiel #8
0
void Scene::WireFacet (Facet& f)
{
  // number of vertices
  int n = f.GetNumVertices();

  // remember previous line color
  ColorF previous_color = foreground_color;

  // =======================================================
  // testing: fog for edgelines to get a depth cueing effect
  // =======================================================
  if (fog_opacity) {
    float cx,cy,cz;
    f.Center(cx,cy,cz); // wastes time !
    SetColor( ColorF_Weighted(0.5*(1-tanh((6/fog_opacity)
			      *(hypot(cx,cy,cz)-fog_distance-1))),
			      previous_color,fog_color) );
  }

  // facet is degenerate (a line)
  if (n == 2)                     // THROW OUT !!!!!!!!!!!!!!
    Line( f[0].p,f[1].p );

  // loop through edges
  else
    if (f.edgelines == Facet::Individual) {
      for (int i = 0, j = n-1; i < n; j = i++)
	if (f.GetEdgeLine(j)) Line( f[j].p,f[i].p );  
    } else
      for (int i = 0, j = n-1; i < n; j = i++)
	Line( f[j].p,f[i].p ); 

  // reset previous color
  if (fog_opacity) SetColor(previous_color);
}
Beispiel #9
0
char Facet::getEdgeOnHorizon(std::vector<Edge *> & horizons) const
{
	for (int i=0; i<3; i++) 
	{
         Edge *opposite = m_edges[i]->getTwin();
		 if(!opposite) 
		 {
			printf("edge not connected\n");
			return 0;
		}
		 Facet * f = (Facet *)(opposite->getFace());
		 
		 if(!f){
			printf("edge has no face\n");
			return 0;
		}
		
		if(f->getIndex() < 0)
		{
			printf("face %d is removed\n", f->getIndex());
			return 0;
		}
		 
		 if(!f->isMarked()) 
		{
			horizons.push_back(opposite);
		}
	}
	
	return 1;
}
Beispiel #10
0
char MembraneDeformer::buildTopology()
{
	const unsigned nv = m_mesh->getNumVertices();
	
	m_topology = new VertexAdjacency[nv];
	
	for(unsigned i = 0; i < nv; i++) {
		VertexAdjacency & v = m_topology[i];
		v.setIndex(i);
		v.m_v = &(m_mesh->getVertices()[i]);
	}
	
	const unsigned nf = m_mesh->getNumFaces();
	unsigned a, b, c;
	
	for(unsigned i = 0; i < nf; i++) {
		a = m_mesh->getIndices()[i * 3];
		b = m_mesh->getIndices()[i * 3 + 1];
		c = m_mesh->getIndices()[i * 3 + 2];
		Facet * f = new Facet(&m_topology[a], &m_topology[b], &m_topology[c]);
		f->setIndex(i);
		for(unsigned j = 0; j < 3; j++) {
			Edge * e = f->edge(j);
			m_topology[e->v0()->getIndex()].addEdge(e);
			m_topology[e->v1()->getIndex()].addEdge(e);
		}
	}
	
	for(unsigned i = 0; i < nv; i++) {
		m_topology[i].findNeighbors();
		m_topology[i].computeWeights();
		m_topology[i].computeDifferentialCoordinate();
	}
	return 1;
}
Beispiel #11
0
//-----------------------------------------------------------------------------
double TriangleCell::facet_area(const Cell& cell, std::size_t facet) const
{
  // Create facet from the mesh and local facet number
  const Facet f(cell.mesh(), cell.entities(1)[facet]);

  // Get global index of vertices on the facet
  const std::size_t v0 = f.entities(0)[0];
  const std::size_t v1 = f.entities(0)[1];

  // Get mesh geometry
  const MeshGeometry& geometry = cell.mesh().geometry();

  // Get the coordinates of the two vertices
  const double* p0 = geometry.x(v0);
  const double* p1 = geometry.x(v1);

  // Compute distance between vertices
  double d = 0.0;
  for (std::size_t i = 0; i < geometry.dim(); i++)
  {
    const double dp = p0[i] - p1[i];
    d += dp*dp;
  }

  return std::sqrt(d);
}
Beispiel #12
0
//-----------------------------------------------------------------------------
void NewDirichletBC::computeBCTopological(std::map<uint, real>& boundary_values,
                                       Facet& facet,
                                       BoundaryCondition::LocalData& data)
{
  // Get cell to which facet belongs (there may be two, but pick first)
  Cell cell(_mesh, facet.entities(facet.dim() + 1)[0]);
  UFCCell ufc_cell(cell);
  
  // Get local index of facet with respect to the cell
  const uint local_facet = cell.index(facet);
  
  // Interpolate function on cell
  g.interpolate(data.w, ufc_cell, *data.finite_element, cell, local_facet);
  
  // Tabulate dofs on cell
  data.dof_map->tabulate_dofs(data.cell_dofs, ufc_cell);

  // Tabulate which dofs are on the facet
  data.dof_map->tabulate_facet_dofs(data.facet_dofs, local_facet);
  
  // Pick values for facet
  for (uint i = 0; i < data.dof_map->num_facet_dofs(); i++)
  {
    const uint dof = data.offset + data.cell_dofs[data.facet_dofs[i]];
    const real value = data.w[data.facet_dofs[i]];
    boundary_values[dof] = value;
  }
}
Beispiel #13
0
void Scene::ConstantFacet (Facet& f)
//
// Uses the global intermediate storage array pix.
//
{
    int i,j;
    short r,g,b;
    long color;
    
    // number of vertices
    int n = f.GetNumVertices();
    
    // facet is degenerate (a line) ----- CURRENTLY DEGENERATE NOT ALLOWED
    if (n == 2) {
	Line(f[0].p,f[1].p);
	return;
    }

    // can't happen !
    if (n < 2 || n > MaxVertices) {
	Warn("Scene::ConstantFacet: number of vertices out of range");
	return;
    }

    if (coloring == Global) {
	r = (short)(mat.color.red   * 255); // normalize to 0..255
	g = (short)(mat.color.green * 255);
	b = (short)(mat.color.blue  * 255);
	
    } else { 		// per-facet colors are assumed
	r = f.front.red;
	g = f.front.green;
        b = f.front.blue;
    } 
     
    // copy projected vertex coordinates to polygon array
    for (i = 0; i < n; i++) pix[i] = f[i].p;
     
    // find color in colormap
    color = LookupColor(r,g,b,&mat);

    // draw outlines if requested
    if (edgelines == 1) 
        Polygon(n,pix,color,Outline|Fill);
    else if (edgelines == 0)
        Polygon(n,pix,color,Fill);
    else if (edgelines == Facet::Individual ) {
	if (f.edgelines == 1)
	    Polygon(n,pix,color,Outline|Fill); 
	else if (f.edgelines == 0)
	    Polygon(n,pix,color,Fill);
	else if (f.edgelines == Facet::Individual) {
	    Polygon(n,pix,color,Fill);
	    for (i = 0, j = n-1; i < n; j = i++) 
	      if ( f.GetEdgeLine(j) ) Line(pix[j],pix[i]);
	}	
    }

}
Beispiel #14
0
  TEST_F(DictionaryTest, FacetLoad){
    string output_file_neighbours = "dictFacetsTestFile_neighbours.dat";
    string output_file_vertexes = "dictFacetsTestFile_vertex.dat";

    ofstream neighbours_ofs(output_file_neighbours.c_str());
    ofstream vertexes_ofs(output_file_vertexes.c_str());

    if(neighbours_ofs.good()){
      neighbours_ofs << "4\n";
      neighbours_ofs << "4 1234 4331 4314 55\n";
      neighbours_ofs << "4 83 7583 38 21\n";
      neighbours_ofs << "4 321 32 1 23\n";
      neighbours_ofs << "4 123 13 22 34\n";
      neighbours_ofs.close(); 
    }

    if(vertexes_ofs.good()){
      vertexes_ofs << "4\n";
      vertexes_ofs << "4 91 89 72 2\n";
      vertexes_ofs << "4 33 123 43 1\n";
      vertexes_ofs << "4 18 22 12 43\n";
      vertexes_ofs << "4 2 32 31 89\n";
      vertexes_ofs.close();
    }

    dictFacets->load("dictFacetsTestFile");

    remove("dictFacetsTestFile_vertex.dat");
    remove("dictFacetsTestFile_neighbours.dat");

    Facet firstFacet = dictFacets->getById(0);
    Facet secondFacet = dictFacets->getById(1);
    //Facet* thirdFacet = dictFacets-> getById(2);
    //Facet* fourthFacet = dictFacets->getById(3);

    // Test firstFacet
    ASSERT_EQ(firstFacet.getNeighboursId()[0],1234);
    ASSERT_EQ(firstFacet.getNeighboursId()[1],4331);
    ASSERT_EQ(firstFacet.getNeighboursId()[2],4314);
    ASSERT_EQ(firstFacet.getNeighboursId()[3],55);

    ASSERT_EQ(firstFacet.getPointsId()[0],91);
    ASSERT_EQ(firstFacet.getPointsId()[1],89);
    ASSERT_EQ(firstFacet.getPointsId()[2],72);
    ASSERT_EQ(firstFacet.getPointsId()[3],2);

    // Test secondFacet
    ASSERT_EQ(secondFacet.getNeighboursId()[0],83);
    ASSERT_EQ(secondFacet.getNeighboursId()[1],7583);
    ASSERT_EQ(secondFacet.getNeighboursId()[2],38);
    ASSERT_EQ(secondFacet.getNeighboursId()[3],21);

    ASSERT_EQ(secondFacet.getPointsId()[0],33);
    ASSERT_EQ(secondFacet.getPointsId()[1],123);
    ASSERT_EQ(secondFacet.getPointsId()[2],43);
    ASSERT_EQ(secondFacet.getPointsId()[3],1);

  }
Beispiel #15
0
Halfedge_handle DegradeAnObject::splitFacet(Facet fs, int index) {
	Halfedge_handle hh1 = fs.halfedge();
	Halfedge_handle hh2 = fs.halfedge()->next();
	Halfedge_handle hh3 = fs.halfedge()->next()->next();
	splitEdgesOfFacet(fs, index);
	Halfedge_handle h = barycentricMesh(fs, index);
	noTVertice(hh1, hh2, hh3, index);
	return h;
}
/**
 * Prints the points around a facet.
 */
void print_facet(const Facet& f)
{
    typedef Vertex::Halfedge_around_facet_const_circulator Circulator;
    Circulator current = f.facet_begin();
    Circulator end = f.facet_begin();
    do {
        cout << current->vertex()->point() << endl;
    } while (++current != end);
    cout << endl;
}
Beispiel #17
0
void ParserOBJ::load(Soup *o) {
  Facet *f;
  Vertex *v;
  Vector3d *n;
  while (token()!=FIN) {
    if (sToken()=="#") {
        lireLigne();
    }
    if (sToken()=="vn") {
      n=new Vector3d;
      skipToken();
      o->addNormal(n);
      int k=0;
      while (token()!=P_EOL) {
        if (token()==REEL) n->set(k,lireReel());
        else n->set(k,double(lireEntier()));
          k++; if (k>3) erreur("lecture normale avec plus de 3 composantes !!!");
        }
    }
    if (sToken()=="f") {
        skipToken();
        f=o->createFacet();
        int a[2];
        while (token()!=P_EOL) {
           f->addVertex(o->getVertex(lireEntier()-1));
           if (sToken()=="/") {
             int k=0;
             skipToken();
             if (sToken()=="/") {skipToken(); k++;}
             a[k]=lireEntier();k++;
             if (sToken()=="/") {
               skipToken();
               a[k]=lireEntier();k++;
             }
             if (k==2) f->addNormal(o->getNormal(a[1]-1));
           }
        }
    }
    if (sToken()=="v") {
        skipToken();
        v=o->createVertex();
        Point3d p;
        int k=0;
        while (token()!=P_EOL) {
          if (token()==REEL) p.set(k,lireReel());
          else p.set(k,double(lireEntier()));
          k++; if (k>3) erreur("lecture sommet avec plus de 3 composantes !!!");
        }
        v->setPoint(p);
    }

    skipToken();
  }
}
Beispiel #18
0
/**
 *	== operator overload.
 */
bool operator==(Facet &f1, Facet &f2)
{
	for (int i = 0; i < 3; i++)
	{
		if (!( f1.hasEdge(f2.getEdge(i))))
		{
			return false;
		}
	}

	return true;
}
Beispiel #19
0
// тестова, просто виводить списки зовнiшнiх точок для кожної гранi
int Convex::PrintOutsideList(FacetList* Polyhedron)
{
    Facet *pF;

    printf("-------------------\n");
    Polyhedron->GetFirst(&pF);
    do {
        pF->PrintCoordinates(1);
    } while ( Polyhedron->GetNext(&pF) );

    printf("===================\n");
    return 1;
};
Beispiel #20
0
Halfedge_handle DegradeAnObject::barycentricMesh(Facet fs, int index) {
	std::vector<Point_3> points;
	Halfedge_handle hh = fs.halfedge();
	Point_3 p1 = hh->vertex()->point();
	points.push_back(p1);
	hh = hh->next();
	while(hh->vertex()->point() != p1) {
		points.push_back(hh->vertex()->point());
		hh = hh->next();
	}
	Halfedge_handle h = polys[index].create_center_vertex(fs.halfedge());
	h->vertex()->point() = meanPoints(points);
	return h;
}
// Constructs HDS for a pane from element connectivity array.
void 
RFC_Pane_overlay::build_hds() {
  RFC_assertion( _base);
  if ( _base->size_of_nodes() == 0) return;

  HDS_builder  B(_hds,true);

  B.begin_surface( _base->size_of_nodes(), _base->size_of_elements());
  // insert the vertices
  for (Size i=0; i<_base->size_of_nodes(); ++i) 
  { B.add_vertex( Vertex::Point()); }

  Element_node_enumerator ene( _base, 1);

  for (int i=_base->size_of_elements(); i>0; --i, ene.next()) {
    B.begin_facet();
    for ( int k=0, ne=ene.size_of_edges(); k<ne; ++k) {
      B.add_vertex_to_facet( ene[k]-1);
    }
    B.end_facet();
  }

  B.end_surface();

  // Normalize border vertices such that every border vertex point to its
  // incident border halfedge.
  _hds.normalize_border_vertices();

  // Insert the vertices in edge/face centers for quadratic elements
  if ( _quadratic) {
    Facet *fs = &*_hds.facets_begin();

    Element_node_enumerator ene( _base, 1);
    for (int i=_base->size_of_elements(); i>0; --i, ene.next(), ++fs) {
      int nn = ene.size_of_nodes();
      int ne = ene.size_of_edges();

      Halfedge *h = fs->halfedge();
      for ( int k=ne; k<ne+ne; ++k) {
	Vertex *v = get_vertex_from_id( ene[k]);
	v->set_halfedge( h);
	h = h->next();
      }
      if ( nn == 9) {
	Vertex *v = get_vertex_from_id( ene[8]);
	v->set_halfedge( fs->halfedge());
      }
    }
  }
}
Beispiel #22
0
void BCIViz::drawNeighbours() const
{
	if(!checkHull()) return;
	
	Facet f = m_hull->getFacet(m_hitTriangle);
	const Vertex p0 = f.getVertex(0);
	const Vertex p1 = f.getVertex(1);
	const Vertex p2 = f.getVertex(2);
	
	ShapeDrawer drawer;
	drawer.drawCircleAround(p0);
	drawer.drawCircleAround(p1);
	drawer.drawCircleAround(p2);
	drawer.drawCircleAround(m_hitP);
}
Beispiel #23
0
	void Constrainer::setConstrains(const Vector& origin, const Vector& normal, ConstrainType constrainType){
		const float epsilon = 1e-4;
		Facet *facet = mesh->getFacet();

		for (int i = 0; i < mesh->getFacetCount(); i++){
			facet->setVertIndexs(i);
			for (int j = 0; j < mesh->getVertPerFacetCount(); j++){
				int index = facet->getVertIndex(j);
				Vector vert = mesh->getVertex(index);
				if (fabsf((vert - origin)*normal) < epsilon){
					setConstrain(index, constrainType);
				}
			}
		}
		delete facet;
	}
Beispiel #24
0
void DegradeAnObject::refineFacetMesh(Point_3 p, Facet &fs, double epsilon, int index) {
	Facet chkF;
	Halfedge_handle h = splitFacet(fs, index);
	//std::cout << getFacetFromPoint(p, chkF, index) << std::endl;
	if(getFacetFromPoint(p, chkF, index)) {
		if(distanceBetweenPointAndFacet(p, chkF.halfedge()->vertex()->point()) > epsilon) {
			refineFacetMesh(p, chkF, epsilon, index);
		}
		else {
			impactAFace(chkF, index);
		}
	}
	else {
		impactAFace(fs, index);
	}
}
Beispiel #25
0
 typename Facet::Plane_3 operator()( Facet& f) {
     typename Facet::Halfedge_handle h = f.halfedge();
     typedef typename Facet::Plane_3  Plane;
     return Plane( h->vertex()->point(),
                   h->next()->vertex()->point(),
                   h->next()->next()->vertex()->point());
 }
Beispiel #26
0
    typename Facet::Plane_3 operator()( Facet& f) 
	{
		typename Facet::Halfedge_handle h = f.halfedge();
        // Facet::Plane_3 is the normal vector type. We assume the
        // CGAL Kernel here and use its global functions.
        return CGAL::cross_product( h->next()->vertex()->point() - h->vertex()->point(),
									h->next()->next()->vertex()->point() - h->next()->vertex()->point() );
    }
Beispiel #27
0
void stellate (Scene &body, float height)
//
//  Adds starlike jags to every facet of the body. The tip 
//  of a jag is placed in the given height over the center 
//  of the facet.
//
{
    float nx,ny,nz,nk,nn,cx,cy,cz,h;
    Vertex* tip;
    Facet* f;
    int i,j,n;

    Scene stella;
    
    for (f = body.TheFacets(); f; f = f->NextFacet() ) {

	// calculate the normal form and the center of the facet
	f->Normal(nx,ny,nz,nk);
	f->Center(cx,cy,cz);

	// normalization of the normal vector to unit length
	nn = hypot(nx,ny,nz);

	// check if facet is degenerate
	if (nn == 0) continue;

	// add the tip vertex of the jag
	h = height / nn;
	tip = &stella.AddVertex( cx+h*nx, cy+h*ny, cz+h*nz );
	
	// add three-sided facets for each side of the jag
	n = f->GetNumVertices();
	for (i = 0, j = n-1; i < n; j = i++) {
	    Facet& s = stella.AddFacet(3);
	    s(0) = &stella.AddVertex( *(*f)(j) );
	    s(1) = &stella.AddVertex( *(*f)(i) );
	    s(2) = tip;
	}
    }
    
    // now clear the original
    body.Remove();
    
    // and add the stellated body instead (duplicate vertices are now removed)
    body.AddScene(stella,Identity);
}
Beispiel #28
0
//-----------------------------------------------------------------------------
bool DirichletBC::on_facet(const double* coordinates, const Facet& facet) const
{
  // Check if the coordinates are on the same line as the line segment
  if (facet.dim() == 1)
  {
    // Create points
    Point p(coordinates[0], coordinates[1]);
    const Point v0 = Vertex(facet.mesh(), facet.entities(0)[0]).point();
    const Point v1 = Vertex(facet.mesh(), facet.entities(0)[1]).point();

    // Create vectors
    const Point v01 = v1 - v0;
    const Point vp0 = v0 - p;
    const Point vp1 = v1 - p;

    // Check if the length of the sum of the two line segments vp0 and
    // vp1 is equal to the total length of the facet
    if ( std::abs(v01.norm() - vp0.norm() - vp1.norm()) < DOLFIN_EPS )
      return true;
    else
      return false;
  }
  // Check if the coordinates are in the same plane as the triangular
  // facet
  else if (facet.dim() == 2)
  {
    // Create points
    const Point p(coordinates[0], coordinates[1], coordinates[2]);
    const Point v0 = Vertex(facet.mesh(), facet.entities(0)[0]).point();
    const Point v1 = Vertex(facet.mesh(), facet.entities(0)[1]).point();
    const Point v2 = Vertex(facet.mesh(), facet.entities(0)[2]).point();

    // Create vectors
    const Point v01 = v1 - v0;
    const Point v02 = v2 - v0;
    const Point vp0 = v0 - p;
    const Point vp1 = v1 - p;
    const Point vp2 = v2 - p;

    // Check if the sum of the area of the sub triangles is equal to
    // the total area of the facet
    if (std::abs(v01.cross(v02).norm() - vp0.cross(vp1).norm()
                 - vp1.cross(vp2).norm() - vp2.cross(vp0).norm()) < DOLFIN_EPS)
    {
      return true;
    }
    else
      return false;
  }

  dolfin_error("DirichletBC.cpp",
               "determine if given point is on facet",
               "Not implemented for given facet dimension");

  return false;
}
Beispiel #29
0
//-----------------------------------------------------------------------------
double QuadrilateralCell::facet_area(const Cell& cell, std::size_t facet) const
{
  // Create facet from the mesh and local facet number
  const Facet f(cell.mesh(), cell.entities(1)[facet]);

  // Get global index of vertices on the facet
  const std::size_t v0 = f.entities(0)[0];
  const std::size_t v1 = f.entities(0)[1];

  // Get mesh geometry
  const MeshGeometry& geometry = cell.mesh().geometry();

  const Point p0 = geometry.point(v0);
  const Point p1 = geometry.point(v1);

  return (p0 - p1).norm();
}
Beispiel #30
0
// утворюємо у кожнiй гранi множину зовнiшнiх точок
void Convex::CreateOutsideSet( FacetList* Polyhedron, PointList *freePointList )
{
    Point P;
    Facet *pF;

    while ( freePointList->Remove( &P ) )
    {
        Polyhedron->GetFirst(&pF);
        do {
            if ( pF->IsOnFacet( P ) > eps )
            {
                pF->listVertices.Add( P );   // добавляємо в множину зовнiшнiх точок
                break;                       // точку добавляємо лише в один список
            };
        } while ( Polyhedron->GetNext(&pF) );
    };

};