Path: blob/devel/ElmerGUI/netgen/libsrc/csg/solid.hpp
3206 views
#ifndef FILE_SOLID1#define FILE_SOLID23/**************************************************************************/4/* File: solid.hh */5/* Author: Joachim Schoeberl */6/* Date: 1. Dez. 95 */7/**************************************************************************/89/*1011Constructive Solid Model (csg)1213*/1415161718class Solid;1920class SolidIterator21{22public:23SolidIterator () { ; }24virtual ~SolidIterator () { ; }25virtual void Do (Solid * sol) = 0;26};27282930class Solid31{32public:3334typedef enum optyp1 { TERM, TERM_REF, SECTION, UNION, SUB, ROOT, DUMMY } optyp;3536private:37char * name;38Primitive * prim;39Solid * s1, * s2;4041optyp op;42bool visited;43double maxh;4445// static int cntnames;4647public:48Solid (Primitive * aprim);49Solid (optyp aop, Solid * as1, Solid * as2 = NULL);50~Solid ();5152const char * Name () const { return name; }53void SetName (const char * aname);5455Solid * Copy (class CSGeometry & geom) const;56void Transform (Transformation<3> & trans);575859void IterateSolid (SolidIterator & it, bool only_once = 0);606162void Boundaries (const Point<3> & p, ARRAY<int> & bounds) const;63int NumPrimitives () const;64void GetSurfaceIndices (ARRAY<int> & surfind) const;65void GetSurfaceIndices (IndexSet & iset) const;6667void GetTangentialSurfaceIndices (const Point<3> & p, ARRAY<int> & surfids, double eps) const;68void GetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, ARRAY<int> & surfids, double eps) const;69void GetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, ARRAY<int> & surfids, double eps) const;707172Primitive * GetPrimitive ()73{ return (op == TERM || op == TERM_REF) ? prim : NULL; }74const Primitive * GetPrimitive () const75{ return (op == TERM || op == TERM_REF) ? prim : NULL; }7677Solid * S1() { return s1; }78Solid * S2() { return s2; }7980// geometric tests8182bool IsIn (const Point<3> & p, double eps = 1e-6) const;83bool IsStrictIn (const Point<3> & p, double eps = 1e-6) const;84bool VectorIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const;85bool VectorStrictIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const;8687bool VectorIn2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,88double eps) const;89bool VectorIn2Rec (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,90double eps) const;919293/// compute localization in point p94void TangentialSolid (const Point<3> & p, Solid *& tansol, ARRAY<int> & surfids, double eps) const;9596/// compute localization in point p tangential to vector t97void TangentialSolid2 (const Point<3> & p, const Vec<3> & t,98Solid *& tansol, ARRAY<int> & surfids, double eps) const;99100/** compute localization in point p, with second order approximation to edge101p + s t + s*s/2 t2 **/102void TangentialSolid3 (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2,103Solid *& tansol, ARRAY<int> & surfids, double eps) const;104105106107/** tangential solid, which follows the edge108p + s t + s*s/2 t2109with second order, and the neighbouring face110p + s t + s*s/2 t2 + r m111with first order112**/113void TangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2,114const Vec<3> & m,115Solid *& tansol, ARRAY<int> & surfids, double eps) const;116117118void CalcOnePrimitiveSpecialPoints (const Box<3> & box, ARRAY<Point<3> > & pts) const;119120///121int Edge (const Point<3> & p, const Vec<3> & v, double eps) const;122///123int OnFace (const Point<3> & p, const Vec<3> & v, double eps) const;124///125void Print (ostream & str) const;126///127void CalcSurfaceInverse ();128///129Solid * GetReducedSolid (const BoxSphere<3> & box) const;130131132void SetMaxH (double amaxh)133{ maxh = amaxh; }134double GetMaxH () const135{ return maxh; }136137void GetSolidData (ostream & ost, int first = 1) const;138static Solid * CreateSolid (istream & ist, const SYMBOLTABLE<Solid*> & solids);139140141static BlockAllocator ball;142void * operator new(size_t /* s */)143{144return ball.Alloc();145}146147void operator delete (void * p)148{149ball.Free (p);150}151152153protected:154///155156void RecBoundaries (const Point<3> & p, ARRAY<int> & bounds,157int & in, int & strin) const;158///159void RecTangentialSolid (const Point<3> & p, Solid *& tansol, ARRAY<int> & surfids,160int & in, int & strin, double eps) const;161162void RecTangentialSolid2 (const Point<3> & p, const Vec<3> & vec,163Solid *& tansol, ARRAY<int> & surfids,164int & in, int & strin, double eps) const;165///166void RecTangentialSolid3 (const Point<3> & p, const Vec<3> & vec,const Vec<3> & vec2,167Solid *& tansol, ARRAY<int> & surfids,168int & in, int & strin, double eps) const;169///170void RecTangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2,171const Vec<3> & m,172Solid *& tansol, ARRAY<int> & surfids,173int & in, int & strin, double eps) const;174175///176void RecEdge (const Point<3> & p, const Vec<3> & v,177int & in, int & strin, int & faces, double eps) const;178///179void CalcSurfaceInverseRec (int inv);180///181Solid * RecGetReducedSolid (const BoxSphere<3> & box, INSOLID_TYPE & in) const;182///183void RecGetSurfaceIndices (ARRAY<int> & surfind) const;184void RecGetTangentialSurfaceIndices (const Point<3> & p, ARRAY<int> & surfids, double eps) const;185void RecGetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, ARRAY<int> & surfids, double eps) const;186void RecGetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2,187ARRAY<int> & surfids, double eps) const;188void RecGetTangentialEdgeSurfaceIndices (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, const Vec<3> & m,189ARRAY<int> & surfids, double eps) const;190void RecGetSurfaceIndices (IndexSet & iset) const;191192void RecCalcOnePrimitiveSpecialPoints (ARRAY<Point<3> > & pts) const;193194friend class SolidIterator;195friend class ClearVisitedIt;196friend class RemoveDummyIterator;197friend class CSGeometry;198};199200201inline ostream & operator<< (ostream & ost, const Solid & sol)202{203sol.Print (ost);204return ost;205}206207208209210211212class ReducePrimitiveIterator : public SolidIterator213{214const BoxSphere<3> & box;215public:216ReducePrimitiveIterator (const BoxSphere<3> & abox)217: SolidIterator(), box(abox) { ; }218virtual ~ReducePrimitiveIterator () { ; }219virtual void Do (Solid * sol)220{221if (sol -> GetPrimitive())222sol -> GetPrimitive() -> Reduce (box);223}224};225226227class UnReducePrimitiveIterator : public SolidIterator228{229public:230UnReducePrimitiveIterator () { ; }231virtual ~UnReducePrimitiveIterator () { ; }232virtual void Do (Solid * sol)233{234if (sol -> GetPrimitive())235sol -> GetPrimitive() -> UnReduce ();236}237};238239240#endif241242243