wzsegment.hxx
来自「有限元学习研究用源代码(老外的),供科研人员参考」· HXX 代码 · 共 187 行
HXX
187 行
#ifndef wzsegment_hxx
#define wzsegment_hxx
#include "wzcolor.hxx"
#include "wzrange.hxx"
class wzRegion;
class wzFace;
class wzEdge;
class wzVertex;
typedef wzInteger wzISegment;
typedef wzIndex wzISegmentType;
typedef enum
{
wzIsRegion,wzIsFace,wzIsEdge,wzIsVertex,wzIs_Nothing
}wzISegmentTypes;
class wzSegmentDescription{
protected:
friend class wzRegion;
friend class wzFace;
friend class wzEdge;
friend class wzVertex;
friend class wzSegment;
public:
wzRange Region;
wzRange Face;
wzRange Edge;
wzRange Vertex;
private:
wzArray<wzName> RName;
wzArray<wzName> FName;
wzArray<wzName> EName;
wzArray<wzName> VName;
wzArray<wzColor> RColor;
wzArray<wzColor> FColor;
wzArray<wzColor> EColor;
wzArray<wzColor> VColor;
wzArray<wzIndex> RType;
wzArray<wzIndex> FType;
wzArray<wzIndex> EType;
wzArray<wzIndex> VType;
void control()
{if(!this){throw wzFailure("no wzSegmentDescription");}}
public:
wzSegmentDescription();
void print();
void use();
void initialize(){;}
};
class wzBadSegment: public wzFailure{
public:
wzDimension D;
wzIndex I;
wzBadSegment(wzDimension d,wzIndex i);
};
class wzRegion{
wzIndex I;
protected:
friend class wzSegmentDescription;
static wzSegmentDescription* s;
public:
operator wzIndex() const {return I;}
wzRegion(wzIndex i=1):I(i){;}
wzRegion(wzName name, wzColor color=wzColor());
wzRegion(wzName name, wzRegion mat);
wzRegion(wzName name, wzRegion mat, wzColor color);
wzBoolean valid() const {return s->Region.valid(I);}
wzBoolean invalid() const {return s->Region.invalid(I);}
wzColor& color() const {return s->RColor[I];}
wzRegion material() const {return *(wzRegion*)&s->RType[I];}
wzRegion type() const {return *(wzRegion*)&s->RType[I];}
const wzName& name() const {return s->RName[I];}
wzRegion& material() {return *(wzRegion*)&s->RType[I];}
void invalidate() {I=0;}
void print() const;
};
class wzFace{
wzIndex I;
protected:
friend class wzSegmentDescription;
static wzSegmentDescription* s;
public:
operator wzIndex() {return I;}
wzFace(wzIndex i=1):I(i){;}
wzFace(wzName name, wzColor color=wzColor());
wzFace(wzName name, wzFace cond);
wzFace(wzName name, wzFace cond, wzColor color);
wzBoolean valid() const {return s->Face.valid(I);}
wzBoolean invalid() const {return s->Face.invalid(I)==0;}
wzColor& color() const {return s->FColor[I];}
const wzName& name() const {return s->FName[I];}
wzFace type() const {return *(wzFace*)&s->FType[I];}
wzFace& type() {return *(wzFace*)&s->FType[I];}
void invalidate() {I=0;}
void print() const;
};
class wzEdge{
wzIndex I;
protected:
friend class wzSegmentDescription;
static wzSegmentDescription* s;
public:
operator wzIndex() {return I;}
wzEdge(wzIndex i=1):I(i){;}
wzEdge(wzName name, wzColor color=wzColor());
wzEdge(wzName name, wzEdge cond);
wzEdge(wzName name, wzEdge cond, wzColor color);
wzBoolean valid() const {return s->Edge.valid(I);}
wzBoolean invalid() const {return s->Edge.invalid(I)==0;}
wzColor& color() const {return s->EColor[I];}
const wzName& name() const {return s->EName[I];}
wzEdge type() const {return *(wzEdge*)&s->EType[I];}
wzEdge& type() {return *(wzEdge*)&s->EType[I];}
void invalidate() {I=0;}
};
class wzVertex{
wzIndex I;
protected:
friend class wzSegmentDescription;
static wzSegmentDescription* s;
public:
operator wzIndex() {return I;}
wzVertex(wzIndex i=1):I(i){;}
wzVertex(wzName name, wzColor color=wzColor());
wzVertex(wzName name, wzVertex cond);
wzVertex(wzName name, wzVertex cond, wzColor color);
wzBoolean valid() const {return s->Vertex.valid(I);}
wzBoolean invalid() const {return s->Vertex.invalid(I)==0;}
wzColor& color() const {return s->VColor[I];}
const wzName& name() const {return s->VName[I];}
wzVertex type() const {return *(wzVertex*)&s->VType[I];}
wzVertex& type() {return *(wzVertex*)&s->VType[I];}
void invalidate() {I=0;}
};
class wzSegment{
private:
wzIndex S;
protected:
friend class wzSegmentDescription;
static wzSegmentDescription* s;
public:
wzSegment():S(0){;}
wzSegment(wzRegion r) :S((r<<2)) {;}
wzSegment(wzFace f) :S((f<<2)+1) {;}
wzSegment(wzEdge e) :S((e<<2)+2) {;}
wzSegment(wzVertex v) :S((v<<2)+3) {;}
wzSegment(wzIndex i, wzDimension codim):S((i<<2)+codim){;}
wzSegment(const wzSegment& ss) :S(ss.S) {;}
wzSegment& operator=( const wzSegment& ss) {S=ss.S; return *this;}
wzBoolean operator!=(const wzSegment& ss) const {return (S!=ss.S);}
wzBoolean operator==(const wzSegment& ss) const {return (S==ss.S);}
wzBoolean valid() const {return (S != 0);}
wzBoolean invalid() const {return (S == 0);}
void invalidate() { (S = 0);}
wzDimension codim() const {return ( S&3 );}
wzBoolean isRegion() const {return ((S&3)==0);}
wzBoolean isFace() const {return ((S&3)==1);}
wzBoolean isEdge() const {return ((S&3)==2);}
wzBoolean isVertex() const {return ((S&3)==3);}
wzBoolean operator()() const {return (S>>2);}
wzIndex index() const {return (S>>2);}
wzRegion region() const {return wzRegion(S>>2);}
wzFace face() const {return wzFace (S>>2);}
wzEdge edge() const {return wzEdge (S>>2);}
wzVertex vertex() const {return wzVertex(S>>2);}
wzColor& color() const
{
switch(S&3){
case 0: return s->RColor[S>>2];
case 1: return s->FColor[S>>2];
case 2: return s->EColor[S>>2];
case 3: return s->VColor[S>>2];
} return s->RColor[0];
}
void print() const;
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?