void VectorFont::Glyph::GlyphLine::glCommands( const gp_Pnt & starting_point, const bool select, const bool marked, const bool no_color, COrientationModifier *pOrientationModifier, gp_Trsf transformation, const float width ) const { gp_Pnt from( starting_point ); gp_Pnt to( starting_point ); from.SetX( starting_point.X() + m_x1); from.SetY( starting_point.Y() + m_y1); from.SetZ( starting_point.Z() ); to.SetX( starting_point.X() + m_x2); to.SetY( starting_point.Y() + m_y2); to.SetZ( starting_point.Z() ); if (pOrientationModifier) { from = pOrientationModifier->Transform(transformation, starting_point.Distance(gp_Pnt(0.0,0.0,0.0)), from, width ); to = pOrientationModifier->Transform(transformation, starting_point.Distance(gp_Pnt(0.0,0.0,0.0)), to, width ); } glBegin(GL_LINE_STRIP); glVertex3d(from.X(), from.Y(), from.Z()); glVertex3d(to.X(), to.Y(), to.Z()); glEnd(); } // End glCommands() method
// ----------------------------------------------------------------------------- bool Compute( vector< double > & positions, gp_Pnt pIn, gp_Pnt pOut, SMESH_Mesh& aMesh, const StdMeshers_LayerDistribution* hyp) { double len = pIn.Distance( pOut ); if ( len <= DBL_MIN ) return error("Too close points of inner and outer shells"); if ( !hyp || !hyp->GetLayerDistribution() ) return error( "Invalid LayerDistribution hypothesis"); myUsedHyps.clear(); myUsedHyps.push_back( hyp->GetLayerDistribution() ); TopoDS_Edge edge = BRepBuilderAPI_MakeEdge( pIn, pOut ); SMESH_Hypothesis::Hypothesis_Status aStatus; if ( !StdMeshers_Regular_1D::CheckHypothesis( aMesh, edge, aStatus )) return error( "StdMeshers_Regular_1D::CheckHypothesis() failed " "with LayerDistribution hypothesis"); BRepAdaptor_Curve C3D(edge); double f = C3D.FirstParameter(), l = C3D.LastParameter(); list< double > params; if ( !StdMeshers_Regular_1D::computeInternalParameters( aMesh, C3D, len, f, l, params, false )) return error("StdMeshers_Regular_1D failed to compute layers distribution"); positions.clear(); positions.reserve( params.size() ); for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++) positions.push_back( *itU / len ); return true; }
//======================================================================= //function : FindBestPoint //purpose : Auxilare for Compute() // V - normal to (P1,P2,PC) //======================================================================= static gp_Pnt FindBestPoint(const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& PC, const gp_Vec& V) { double a = P1.Distance(P2); double b = P1.Distance(PC); double c = P2.Distance(PC); if( a < (b+c)/2 ) return PC; else { // find shift along V in order to a became equal to (b+c)/2 double shift = sqrt( a*a + (b*b-c*c)*(b*b-c*c)/16/a/a - (b*b+c*c)/2 ); gp_Dir aDir(V); gp_Pnt Pbest( PC.X() + aDir.X()*shift, PC.Y() + aDir.Y()*shift, PC.Z() + aDir.Z()*shift ); return Pbest; } }
FastArc::FastArc(gp_Pnt A,gp_Pnt B, gp_Pnt C, bool cw, gp_Circ circ) { if(!cw) { gp_Pnt temp = A; A = B; B = temp; circ.SetAxis(circ.Axis().Reversed()); } this->A = A; this->B = B; this->C = C; this->cw = cw; this->m_circ = circ; this->m_flipped = false; a1 = atan2(A.Y()-C.Y(), A.X()-C.X()); a2 = atan2(B.Y()-C.Y(), B.X()-C.X()); if(a2<a1) a2+=2*M_PI; da = a2 - a1; rad = C.Distance(A); //TODO: compute how far apart the angles are, signed! //da = fmod(a2-a1,2*Pi); #ifdef CHECKFASTARC double tax = GetXatU(0); double tay = GetYatU(0); double tbx = GetXatU(1); double tby = GetYatU(1); if(tax != A.X() || tay != A.Y() || tbx != B.X() || tby != B.Y()) { int x=0; x++; } #endif }
void VectorFont::Glyph::GlyphArc::glCommands( const gp_Pnt & starting_point, const bool select, const bool marked, const bool no_color, COrientationModifier *pOrientationModifier, gp_Trsf transformation, const float width) const { glBegin(GL_LINE_STRIP); std::list<gp_Pnt> vertices = Interpolate( starting_point, 20 ); for (std::list<gp_Pnt>::iterator l_itVertex = vertices.begin(); l_itVertex != vertices.end(); l_itVertex++) { if (pOrientationModifier) *l_itVertex = pOrientationModifier->Transform(transformation, starting_point.Distance(gp_Pnt(0.0,0.0,0.0)), *l_itVertex, width ); glVertex3d(l_itVertex->X(), l_itVertex->Y(), l_itVertex->Z()); } // End for glEnd(); } // End glCommands() method