Esempio n. 1
0
bool CSPrimSphericalShell::IsInside(const double* Coord, double /*tol*/)
{
	if (Coord==NULL) return false;
	double out[3];
	const double* center = m_Center.GetCartesianCoords();
	TransformCoordSystem(Coord,out,m_MeshType,CARTESIAN);
	if (m_Transform)
		m_Transform->InvertTransform(out,out);
	double dist=sqrt(pow(out[0]-center[0],2)+pow(out[1]-center[1],2)+pow(out[2]-center[2],2));
	if (fabs(dist-psRadius.GetValue())< psShellWidth.GetValue()/2.0)
		return true;
	return false;
}
Esempio n. 2
0
bool CSPrimRotPoly::IsInside(const double* inCoord, double /*tol*/)
{
	if (inCoord==NULL) return false;

	double Coord[3];
	//transform incoming coordinates into cartesian coords
	TransformCoordSystem(inCoord,Coord,m_MeshType,CARTESIAN);
	if (m_Transform && Type==ROTPOLY)
		TransformCoords(Coord,true, CARTESIAN);

	double origin[3]={0,0,0};
	double dir[3]={0,0,0};
	dir[m_RotAxisDir] = 1;
	double foot;
	double dist;
	Point_Line_Distance(Coord, origin, dir, foot, dist);

	int raP = (m_RotAxisDir+1)%3;
	int raPP = (m_RotAxisDir+2)%3;
	double alpha = atan2(Coord[raPP],Coord[raP]);
	if (raP == m_NormDir)
		alpha=alpha-M_PI/2;
	if (alpha<0)
		alpha+=2*M_PI;

	origin[0] = dist;origin[1] = dist;origin[2] = dist;
	origin[m_NormDir] = 0;
	origin[m_RotAxisDir] = foot;

	if (alpha<m_StartStopAng[0])
		alpha+=2*M_PI;

	if ((CSPrimPolygon::IsInside(origin)) && (alpha<m_StartStopAng[1]))
		return true;

	dist*=-1;
	alpha=alpha+M_PI;
	if (alpha>2*M_PI)
		alpha-=2*M_PI;

	if (alpha<m_StartStopAng[0])
		alpha+=2*M_PI;

	if (alpha>m_StartStopAng[1])
		return false;

	origin[0] = dist;origin[1] = dist;origin[2] = dist;
	origin[m_NormDir] = 0;
	origin[m_RotAxisDir] = foot;
	return CSPrimPolygon::IsInside(origin);
}
Esempio n. 3
0
bool CSPrimBox::IsInside(const double* Coord, double /*tol*/)
{
    if (Coord==NULL) return false;

    const double* start = m_Coords[0].GetCoords(m_PrimCoordSystem);
    const double* stop  = m_Coords[1].GetCoords(m_PrimCoordSystem);
    double pos[3] = {Coord[0],Coord[1],Coord[2]};

    TransformCoords(pos, true, m_MeshType);
    //transform incoming coordinates into the coorindate system of the primitive
    TransformCoordSystem(pos,pos,m_MeshType,m_PrimCoordSystem);

    if (m_PrimCoordSystem!=UNDEFINED_CS)
        return CoordInRange(pos, start, stop, m_PrimCoordSystem);
    else
        return CoordInRange(pos, start, stop, m_MeshType);
}
Esempio n. 4
0
void ParameterCoord::Update()
{
	double coords[3] = {m_Coords[0]->GetValue(),m_Coords[1]->GetValue(),m_Coords[2]->GetValue()};
	TransformCoordSystem(coords, m_CartesianCoords, m_CoordSystem, CARTESIAN);
	TransformCoordSystem(coords, m_CylindricalCoords, m_CoordSystem, CYLINDRICAL);
}
Esempio n. 5
0
bool CSPrimPolygon::IsInside(const double* inCoord, double /*tol*/)
{
	if (inCoord==NULL) return false;
	if (vCoords.size()<2) return false;

	double Coord[3];
	//transform incoming coordinates into cartesian coords
	TransformCoordSystem(inCoord,Coord,m_MeshType,CARTESIAN);
	if (m_Transform && Type==POLYGON)
		TransformCoords(Coord,true, CARTESIAN);

	for (unsigned int n=0;n<3;++n)
		if ((m_BoundBox[2*n]>Coord[n]) || (m_BoundBox[2*n+1]<Coord[n])) return false;

	double x=0,y=0;
	int nP = (m_NormDir+1)%3;
	int nPP = (m_NormDir+2)%3;
	x = Coord[nP];
	y = Coord[nPP];

	int wn = 0;

	size_t np = vCoords.size()/2;
	double x1 = vCoords[2*np-2].GetValue();
	double y1 = vCoords[2*np-1].GetValue();
	double x2 = vCoords[0].GetValue();
	double y2 = vCoords[1].GetValue();
	bool startover = y1 >= y ? true : false;
	bool endover;

	for (size_t i=0;i<np;++i)
	{
		x2 = vCoords[2*i].GetValue();
		y2 = vCoords[2*i+1].GetValue();

		//check if coord is on a cartesian edge exactly
		if ((x2==x1) && (x1==x) && ( ((y<y1) && (y>y2)) || ((y>y1) && (y<y2)) ))
			return true;
		if ((y2==y1) && (y1==y) && ( ((x<x1) && (x>x2)) || ((x>x1) && (x<x2)) ))
			return true;

		endover = y2 >= y ? true : false;
		if (startover != endover)
		{
			if ((y2 - y)*(x2 - x1) <= (y2 - y1)*(x2 - x))
			{
				if (endover) wn ++;
			}
			else
			{
				if (!endover) wn --;
			}
		}
		startover = endover;
		y1 = y2;
		x1 = x2;
	}
	// return true if polygon is inside the polygon
	if (wn != 0)
		return true;

	return false;
}